mirror of
https://github.com/YunoHost/yunohost.git
synced 2024-09-03 20:06:10 +02:00
Fix some inconsistent stuff in the migration considering app_setting() now maps get/set/delete of legacy permission setting to the new permission system ... gotta use the low-level helpers to really access the value of legacy settings
This commit is contained in:
parent
66f5d14e0c
commit
092caba505
1 changed files with 27 additions and 17 deletions
|
@ -6,7 +6,7 @@ from yunohost.utils.error import YunohostError
|
||||||
from moulinette.utils.log import getActionLogger
|
from moulinette.utils.log import getActionLogger
|
||||||
|
|
||||||
from yunohost.tools import Migration
|
from yunohost.tools import Migration
|
||||||
from yunohost.app import app_setting, _installed_apps
|
from yunohost.app import app_setting, _installed_apps, _get_app_settings, _set_app_settings
|
||||||
from yunohost.permission import user_permission_list, permission_create, permission_sync_to_user
|
from yunohost.permission import user_permission_list, permission_create, permission_sync_to_user
|
||||||
from yunohost.utils.legacy import legacy_permission_label
|
from yunohost.utils.legacy import legacy_permission_label
|
||||||
|
|
||||||
|
@ -103,17 +103,20 @@ class MyMigration(Migration):
|
||||||
else:
|
else:
|
||||||
apps = [app]
|
apps = [app]
|
||||||
|
|
||||||
def _get_setting(app, name):
|
|
||||||
s = app_setting(app, name)
|
|
||||||
return s.split(',') if s else []
|
|
||||||
|
|
||||||
for app in apps:
|
for app in apps:
|
||||||
skipped_urls = [uri for uri in _get_setting(app, 'skipped_uris') if uri != '/']
|
|
||||||
skipped_urls += ['re:' + regex for regex in _get_setting(app, 'skipped_regex')]
|
settings = _get_app_settings(app) or {}
|
||||||
unprotected_urls = [uri for uri in _get_setting(app, 'unprotected_uris') if uri != '/']
|
|
||||||
unprotected_urls += ['re:' + regex for regex in _get_setting(app, 'unprotected_regex')]
|
def _setting(name):
|
||||||
protected_urls = [uri for uri in _get_setting(app, 'protected_uris') if uri != '/']
|
s = settings.get(name)
|
||||||
protected_urls += ['re:' + regex for regex in _get_setting(app, 'protected_regex')]
|
return s.split(',') if s else []
|
||||||
|
|
||||||
|
skipped_urls = [uri for uri in _setting('skipped_uris') if uri != '/']
|
||||||
|
skipped_urls += ['re:' + regex for regex in _setting('skipped_regex')]
|
||||||
|
unprotected_urls = [uri for uri in _setting('unprotected_uris') if uri != '/']
|
||||||
|
unprotected_urls += ['re:' + regex for regex in _setting('unprotected_regex')]
|
||||||
|
protected_urls = [uri for uri in _setting('protected_uris') if uri != '/']
|
||||||
|
protected_urls += ['re:' + regex for regex in _setting('protected_regex')]
|
||||||
|
|
||||||
if skipped_urls != []:
|
if skipped_urls != []:
|
||||||
permission_create(app + ".legacy_skipped_uris", additional_urls=skipped_urls,
|
permission_create(app + ".legacy_skipped_uris", additional_urls=skipped_urls,
|
||||||
|
@ -129,12 +132,19 @@ class MyMigration(Migration):
|
||||||
show_tile=False, allowed=user_permission_list()['permissions'][app + ".main"]['allowed'],
|
show_tile=False, allowed=user_permission_list()['permissions'][app + ".main"]['allowed'],
|
||||||
protected=True, sync_perm=False)
|
protected=True, sync_perm=False)
|
||||||
|
|
||||||
app_setting(app, 'skipped_uris', delete=True)
|
legacy_permission_settings = [
|
||||||
app_setting(app, 'unprotected_uris', delete=True)
|
"skipped_uris",
|
||||||
app_setting(app, 'protected_uris', delete=True)
|
"unprotected_uris",
|
||||||
app_setting(app, 'skipped_regex', delete=True)
|
"protected_uris",
|
||||||
app_setting(app, 'unprotected_regex', delete=True)
|
"skipped_regex",
|
||||||
app_setting(app, 'protected_regex', delete=True)
|
"unprotected_regex",
|
||||||
|
"protected_regex"
|
||||||
|
]
|
||||||
|
for key in legacy_permission_settings:
|
||||||
|
if key in settings:
|
||||||
|
del settings[key]
|
||||||
|
|
||||||
|
_set_app_settings(app, settings)
|
||||||
|
|
||||||
permission_sync_to_user()
|
permission_sync_to_user()
|
||||||
|
|
||||||
|
|
Loading…
Add table
Reference in a new issue