From bbd6cae3d7c0ea40064ea29fe82f000c5f7db9f6 Mon Sep 17 00:00:00 2001 From: Bai Date: Fri, 27 Nov 2020 16:58:57 +0800 Subject: [PATCH] =?UTF-8?q?perf(org):=20=E4=BC=98=E5=8C=96=E8=8E=B7?= =?UTF-8?q?=E5=8F=96org=5Fname=E5=AD=97=E6=AE=B5?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- apps/orgs/utils.py | 12 ++++++++---- 1 file changed, 8 insertions(+), 4 deletions(-) diff --git a/apps/orgs/utils.py b/apps/orgs/utils.py index d86e707c5..356fac9bd 100644 --- a/apps/orgs/utils.py +++ b/apps/orgs/utils.py @@ -71,7 +71,9 @@ def construct_org_mapper(): default_org = Organization.default() org_mapper.update({ '': default_org, - Organization.DEFAULT_ID: default_org + Organization.DEFAULT_ID: default_org, + Organization.ROOT_ID: Organization.root(), + Organization.SYSTEM_ID: Organization.system() }) return org_mapper @@ -92,9 +94,11 @@ def get_org_name_by_id(org_id): org_id = str(org_id) org_mapper = get_org_mapper() org = org_mapper.get(org_id) - if not org: - org = Organization.objects.filter(id=org_id).first() - return org.name + if org: + org_name = org.name + else: + org_name = 'Not Found' + return org_name def get_current_org_id_for_serializer():