From 72362274ced1c2aa76a4efcee27cc660bd47fc46 Mon Sep 17 00:00:00 2001 From: ibuler Date: Tue, 12 Mar 2024 18:50:30 +0800 Subject: [PATCH] =?UTF-8?q?perf:=20=E4=BC=98=E5=8C=96=20console=5Forgs=20?= =?UTF-8?q?=E7=9A=84=E9=80=89=E6=8B=A9=E9=97=AE=E9=A2=98?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- apps/rbac/models/rolebinding.py | 12 +++++++----- 1 file changed, 7 insertions(+), 5 deletions(-) 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