perf: 优化 console_orgs 的选择问题

pull/12804/head
ibuler 2024-03-12 18:50:30 +08:00 committed by Bryan
parent cfb1d306a3
commit 72362274ce
1 changed files with 7 additions and 5 deletions

View File

@ -152,13 +152,15 @@ class RoleBinding(JMSBaseModel):
orgs = cls.orgs_order_by_name(orgs)
workbench_perm = 'rbac.view_workbench'
# 全局组织
has_root_org = False
root_org = Organization.root()
if orgs and perm != workbench_perm and user.has_perm('orgs.view_rootorg'):
root_org = Organization.root()
orgs = [root_org, *list(orgs)]
has_root_org = True
elif orgs and perm == workbench_perm and user.has_perm('orgs.view_alljoinedorg'):
# Todo: 先复用组织
root_org = Organization.root()
root_org.name = _("All organizations")
root_org.name = _('All organizations')
has_root_org = True
if has_root_org and system_bindings:
orgs = [root_org, *list(orgs)]
return orgs