mirror of
https://github.com/YunoHost/yunohost.git
synced 2024-09-03 20:06:10 +02:00
Set sub-permission labels as 'Mainlabel (Sublabel)'
This commit is contained in:
parent
c4dc8b4cea
commit
dd9df5943e
3 changed files with 11 additions and 5 deletions
|
@ -283,7 +283,7 @@ ynh_permission_create() {
|
||||||
if [[ -n ${label:-} ]]; then
|
if [[ -n ${label:-} ]]; then
|
||||||
label=",label='$label'"
|
label=",label='$label'"
|
||||||
else
|
else
|
||||||
label=",label='$YNH_APP_LABEL ($permission)'"
|
label=",label='$permission'"
|
||||||
fi
|
fi
|
||||||
|
|
||||||
if [[ -n ${show_tile:-} ]]
|
if [[ -n ${show_tile:-} ]]
|
||||||
|
|
|
@ -429,7 +429,7 @@ def app_upgrade(app=[], url=None, file=None, force=False):
|
||||||
"""
|
"""
|
||||||
from packaging import version
|
from packaging import version
|
||||||
from yunohost.hook import hook_add, hook_remove, hook_exec, hook_callback
|
from yunohost.hook import hook_add, hook_remove, hook_exec, hook_callback
|
||||||
from yunohost.permission import permission_sync_to_user, user_permission_list
|
from yunohost.permission import permission_sync_to_user
|
||||||
from yunohost.regenconf import manually_modified_files
|
from yunohost.regenconf import manually_modified_files
|
||||||
|
|
||||||
apps = app
|
apps = app
|
||||||
|
@ -521,7 +521,6 @@ def app_upgrade(app=[], url=None, file=None, force=False):
|
||||||
env_dict["YNH_APP_ID"] = app_id
|
env_dict["YNH_APP_ID"] = app_id
|
||||||
env_dict["YNH_APP_INSTANCE_NAME"] = app_instance_name
|
env_dict["YNH_APP_INSTANCE_NAME"] = app_instance_name
|
||||||
env_dict["YNH_APP_INSTANCE_NUMBER"] = str(app_instance_nb)
|
env_dict["YNH_APP_INSTANCE_NUMBER"] = str(app_instance_nb)
|
||||||
env_dict["YNH_APP_LABEL"] = user_permission_list(full=True, ignore_system_perms=True, full_path=False)['permissions'][app_id+".main"]['label']
|
|
||||||
env_dict["YNH_APP_UPGRADE_TYPE"] = upgrade_type
|
env_dict["YNH_APP_UPGRADE_TYPE"] = upgrade_type
|
||||||
env_dict["YNH_APP_MANIFEST_VERSION"] = str(app_new_version)
|
env_dict["YNH_APP_MANIFEST_VERSION"] = str(app_new_version)
|
||||||
env_dict["YNH_APP_CURRENT_VERSION"] = str(app_current_version)
|
env_dict["YNH_APP_CURRENT_VERSION"] = str(app_current_version)
|
||||||
|
@ -756,7 +755,6 @@ def app_install(operation_logger, app, label=None, args=None, no_remove_on_failu
|
||||||
env_dict["YNH_APP_ID"] = app_id
|
env_dict["YNH_APP_ID"] = app_id
|
||||||
env_dict["YNH_APP_INSTANCE_NAME"] = app_instance_name
|
env_dict["YNH_APP_INSTANCE_NAME"] = app_instance_name
|
||||||
env_dict["YNH_APP_INSTANCE_NUMBER"] = str(instance_number)
|
env_dict["YNH_APP_INSTANCE_NUMBER"] = str(instance_number)
|
||||||
env_dict["YNH_APP_LABEL"] = label
|
|
||||||
env_dict["YNH_APP_MANIFEST_VERSION"] = manifest.get("version", "?")
|
env_dict["YNH_APP_MANIFEST_VERSION"] = manifest.get("version", "?")
|
||||||
|
|
||||||
# Start register change on system
|
# Start register change on system
|
||||||
|
|
|
@ -87,17 +87,25 @@ def user_permission_list(short=False, full=False, ignore_system_perms=False, ful
|
||||||
perm["additional_urls"] = infos.get("additionalUrls", [])
|
perm["additional_urls"] = infos.get("additionalUrls", [])
|
||||||
|
|
||||||
if full_path:
|
if full_path:
|
||||||
app_base_path = apps_base_path[app] if app in apps_base_path else "" # Meh in some situation where the app is currently installed/removed, this function may be called and we still need to act as if the corresponding permission indeed exists ... dunno if that's really the right way to proceed but okay.
|
app_base_path = apps_base_path[app] if app in apps_base_path else "" # Meh in some situation where the app is currently installed/removed, this function may be called and we still need to act as if the corresponding permission indeed exists ... dunno if that's really the right way to proceed but okay.
|
||||||
perm["url"] = _get_absolute_url(perm["url"], app_base_path)
|
perm["url"] = _get_absolute_url(perm["url"], app_base_path)
|
||||||
perm["additional_urls"] = [_get_absolute_url(url, app_base_path) for url in perm["additional_urls"]]
|
perm["additional_urls"] = [_get_absolute_url(url, app_base_path) for url in perm["additional_urls"]]
|
||||||
|
|
||||||
permissions[name] = perm
|
permissions[name] = perm
|
||||||
|
|
||||||
|
# Make sure labels for sub-permissions are the form " Applabel (Sublabel) "
|
||||||
|
if full:
|
||||||
|
for name, infos in {k: v for k, v in permissions if not k.endswith(".main")}:
|
||||||
|
main_perm_name = name.split(".")[0] + ".main"
|
||||||
|
main_perm_label = permissions[main_perm_name]["label"]
|
||||||
|
infos["label"] = "%s (%s)" % (main_perm_label, infos["label"])
|
||||||
|
|
||||||
if short:
|
if short:
|
||||||
permissions = permissions.keys()
|
permissions = permissions.keys()
|
||||||
|
|
||||||
return {'permissions': permissions}
|
return {'permissions': permissions}
|
||||||
|
|
||||||
|
|
||||||
@is_unit_operation()
|
@is_unit_operation()
|
||||||
def user_permission_update(operation_logger, permission, add=None, remove=None,
|
def user_permission_update(operation_logger, permission, add=None, remove=None,
|
||||||
label=None, show_tile=None,
|
label=None, show_tile=None,
|
||||||
|
|
Loading…
Add table
Reference in a new issue