fix(module-key): make module keys standalone MD format with system_key relation
This commit is contained in:
@@ -21,6 +21,7 @@ class PermissionsRepository:
|
||||
UserScopePermission.scope_type,
|
||||
Company.company_key,
|
||||
Site.site_key,
|
||||
Module.system_key,
|
||||
Module.module_key,
|
||||
UserScopePermission.action,
|
||||
)
|
||||
@@ -55,13 +56,10 @@ class PermissionsRepository:
|
||||
if source == "group":
|
||||
_, scope_type, scope_id, system_key, module_key, action = row
|
||||
if module_key == "__system__":
|
||||
module_key = f"{system_key}.__system__"
|
||||
elif module_key and "." not in module_key:
|
||||
module_key = f"{system_key}.{module_key}"
|
||||
module_key = f"__system__{system_key}"
|
||||
else:
|
||||
_, scope_type, company_key, site_key, module_key, action = row
|
||||
_, scope_type, company_key, site_key, system_key, module_key, action = row
|
||||
scope_id = company_key if scope_type == "company" else site_key
|
||||
system_key = module_key.split(".", 1)[0] if isinstance(module_key, str) and "." in module_key else None
|
||||
key = (scope_type, scope_id or "", system_key, module_key, action)
|
||||
if key in dedup:
|
||||
continue
|
||||
@@ -146,6 +144,7 @@ class PermissionsRepository:
|
||||
UserScopePermission.scope_type,
|
||||
Company.company_key,
|
||||
Site.site_key,
|
||||
Module.system_key,
|
||||
Module.module_key,
|
||||
UserScopePermission.action,
|
||||
UserScopePermission.created_at,
|
||||
@@ -200,14 +199,14 @@ class PermissionsRepository:
|
||||
row_scope_type,
|
||||
company_key,
|
||||
site_key,
|
||||
system_key,
|
||||
module_key,
|
||||
action,
|
||||
created_at,
|
||||
) = row
|
||||
scope_id = company_key if row_scope_type == "company" else site_key
|
||||
system_key = module_key.split(".", 1)[0] if isinstance(module_key, str) and "." in module_key else None
|
||||
module_name = module_key.split(".", 1)[1] if isinstance(module_key, str) and "." in module_key else module_key
|
||||
if module_name == "__system__":
|
||||
module_name = module_key
|
||||
if isinstance(module_name, str) and module_name.startswith("__system__"):
|
||||
module_name = None
|
||||
items.append(
|
||||
{
|
||||
|
||||
Reference in New Issue
Block a user