From c645ca9aea3d33e560dd45bd2ff2a2ba4bab6e07 Mon Sep 17 00:00:00 2001 From: Bai Date: Thu, 22 Dec 2022 17:43:03 +0800 Subject: [PATCH] =?UTF-8?q?fix:=20=E4=BF=AE=E6=94=B9=E7=82=B9=E5=87=BB?= =?UTF-8?q?=E6=88=91=E7=9A=84=E6=8E=88=E6=9D=83=E6=A0=91=E8=8A=82=E7=82=B9?= =?UTF-8?q?=E6=8A=A5=E9=94=99=E7=9A=84=E9=97=AE=E9=A2=98?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- apps/perms/urls/user_permission.py | 3 ++- apps/perms/utils/user_perm.py | 6 +++--- 2 files changed, 5 insertions(+), 4 deletions(-) diff --git a/apps/perms/urls/user_permission.py b/apps/perms/urls/user_permission.py index e76f29ed1..d15036ed5 100644 --- a/apps/perms/urls/user_permission.py +++ b/apps/perms/urls/user_permission.py @@ -31,14 +31,15 @@ user_permission_urlpatterns = [ path('/nodes/children/tree/', api.UserPermedNodeChildrenAsTreeApi.as_view(), name='user-node-children-as-tree'), # tree-node-with-asset + # 异步树 path('/nodes/children-with-assets/tree/', api.UserPermedNodeChildrenWithAssetsAsTreeApi.as_view(), name='user-node-children-with-assets-as-tree'), - path('/nodes/children-with-k8s/tree/', api.UserGrantedK8sAsTreeApi.as_view(), name='user-nodes-children-with-k8s-as-tree'), + # 同步树 path('/nodes-with-assets/tree/', api.UserPermedNodesWithAssetsAsTreeApi.as_view(), name='user-nodes-with-assets-as-tree'), # accounts diff --git a/apps/perms/utils/user_perm.py b/apps/perms/utils/user_perm.py index ba7f37855..2b2172e39 100644 --- a/apps/perms/utils/user_perm.py +++ b/apps/perms/utils/user_perm.py @@ -107,7 +107,7 @@ class UserPermAssetUtil(AssetPermissionPermAssetUtil): asset_ids = set() children_from_granted = UserAssetGrantedTreeNodeRelation.objects \ .filter(user=self.user) \ - .filter(node_key__startwith=f'{node.key}:', node_from=node.NodeFrom.granted) \ + .filter(node_key__startswith=f'{node.key}:', node_from=node.NodeFrom.granted) \ .only('node_id', 'node_key') for n in children_from_granted: n.id = n.node_id @@ -118,13 +118,13 @@ class UserPermAssetUtil(AssetPermissionPermAssetUtil): # 查询节点下资产授权的节点 children_from_assets = UserAssetGrantedTreeNodeRelation.objects \ .filter(user=self.user) \ - .filter(node_key__startwith=f'{node.key}:', node_from=node.NodeFrom.asset) \ + .filter(node_key__startswith=f'{node.key}:', node_from=node.NodeFrom.asset) \ .values_list('node_id', flat=True) children_from_assets = set(children_from_assets) if node.node_from == node.NodeFrom.asset: children_from_assets.add(node.id) _asset_ids = Asset.objects \ - .filter(node__id__in=children_from_assets) \ + .filter(nodes__id__in=children_from_assets) \ .filter(granted_by_permissions__id__in=self.perm_ids) \ .distinct() \ .order_by() \