From da588ce0ae651b0b9a53e12f5d29850553b253b2 Mon Sep 17 00:00:00 2001 From: feng626 <1304903146@qq.com> Date: Wed, 28 Jul 2021 14:33:02 +0800 Subject: [PATCH] =?UTF-8?q?perf:=20=E4=BB=A3=E7=A0=81=E4=BC=98=E5=8C=96?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- apps/perms/utils/asset/user_permission.py | 16 +++++++++------- 1 file changed, 9 insertions(+), 7 deletions(-) diff --git a/apps/perms/utils/asset/user_permission.py b/apps/perms/utils/asset/user_permission.py index 24b0e8eab..b91039dcc 100644 --- a/apps/perms/utils/asset/user_permission.py +++ b/apps/perms/utils/asset/user_permission.py @@ -549,13 +549,15 @@ class UserGrantedNodesQueryUtils(UserGrantedUtilsBase): return self.get_top_level_nodes() nodes = PermNode.objects.none() - if key != PermNode.FAVORITE_NODE_KEY: - node = PermNode.objects.get(key=key) - granted_status = node.get_granted_status(self.user) - if granted_status == NodeFrom.granted: - nodes = PermNode.objects.filter(parent_key=key) - elif granted_status in (NodeFrom.asset, NodeFrom.child): - nodes = self.get_indirect_granted_node_children(key) + if key == PermNode.FAVORITE_NODE_KEY: + return nodes + + node = PermNode.objects.get(key=key) + granted_status = node.get_granted_status(self.user) + if granted_status == NodeFrom.granted: + nodes = PermNode.objects.filter(parent_key=key) + elif granted_status in (NodeFrom.asset, NodeFrom.child): + nodes = self.get_indirect_granted_node_children(key) nodes = self.sort(nodes) return nodes