mirror of
https://github.com/YunoHost/yunohost.git
synced 2024-09-03 20:06:10 +02:00
Move 'label' migration to migrate_legacy_permission_settings in legacy.py, because the previous code could led to some inconsistencies when restoring apps backuped before the migration
This commit is contained in:
parent
e047b67b1d
commit
e91f2de0dc
2 changed files with 6 additions and 11 deletions
|
@ -6,7 +6,6 @@ from yunohost.utils.error import YunohostError
|
|||
from moulinette.utils.log import getActionLogger
|
||||
|
||||
from yunohost.tools import Migration
|
||||
from yunohost.app import app_setting, _installed_apps
|
||||
from yunohost.permission import user_permission_list
|
||||
from yunohost.utils.legacy import migrate_legacy_permission_settings
|
||||
|
||||
|
@ -39,11 +38,6 @@ class MyMigration(Migration):
|
|||
ldap = _get_ldap_interface()
|
||||
permission_list = user_permission_list(full=True)["permissions"]
|
||||
|
||||
labels = {}
|
||||
for app in _installed_apps():
|
||||
labels[app] = app_setting(app, 'label') or permission_list[app + ".main"].get("label") or app
|
||||
app_setting(app, 'label', delete=True)
|
||||
|
||||
for permission in permission_list:
|
||||
if permission.split('.')[0] == 'mail':
|
||||
ldap.update('cn=%s,ou=permission' % permission, {
|
||||
|
@ -74,19 +68,18 @@ class MyMigration(Migration):
|
|||
'isProtected': ["TRUE"],
|
||||
})
|
||||
else:
|
||||
label = labels[permission.split('.')[0]].title()
|
||||
|
||||
app, subperm_name = permission.split('.')
|
||||
if permission.endswith(".main"):
|
||||
ldap.update('cn=%s,ou=permission' % permission, {
|
||||
'authHeader': ["TRUE"],
|
||||
'label': [label],
|
||||
'label': [app], # Note that this is later re-changed during the call to migrate_legacy_permission_settings() if a 'label' setting exists
|
||||
'showTile': ["TRUE"],
|
||||
'isProtected': ["FALSE"]
|
||||
})
|
||||
else:
|
||||
ldap.update('cn=%s,ou=permission' % permission, {
|
||||
'authHeader': ["TRUE"],
|
||||
'label': [permission.split('.')[1]],
|
||||
'label': [subperm_name.title()],
|
||||
'showTile': ["FALSE"],
|
||||
'isProtected': ["TRUE"]
|
||||
})
|
||||
|
|
|
@ -162,6 +162,9 @@ def migrate_legacy_permission_settings(app=None):
|
|||
for app in apps:
|
||||
|
||||
settings = _get_app_settings(app) or {}
|
||||
if settings.get("label"):
|
||||
user_permission_update(app + ".main", label=settings["label"], sync_perm=False)
|
||||
del settings["label"]
|
||||
|
||||
def _setting(name):
|
||||
s = settings.get(name)
|
||||
|
@ -203,4 +206,3 @@ def migrate_legacy_permission_settings(app=None):
|
|||
_set_app_settings(app, settings)
|
||||
|
||||
permission_sync_to_user()
|
||||
|
||||
|
|
Loading…
Add table
Reference in a new issue