diff --git a/apps/rbac/models/rolebinding.py b/apps/rbac/models/rolebinding.py index e9d636354..11d91c911 100644 --- a/apps/rbac/models/rolebinding.py +++ b/apps/rbac/models/rolebinding.py @@ -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