mirror of https://github.com/jumpserver/jumpserver
fix: 修改点击我的授权树节点报错的问题
parent
6ff104c100
commit
c645ca9aea
|
@ -31,14 +31,15 @@ user_permission_urlpatterns = [
|
|||
path('<str:user>/nodes/children/tree/', api.UserPermedNodeChildrenAsTreeApi.as_view(),
|
||||
name='user-node-children-as-tree'),
|
||||
# tree-node-with-asset
|
||||
# 异步树
|
||||
path('<str:user>/nodes/children-with-assets/tree/',
|
||||
api.UserPermedNodeChildrenWithAssetsAsTreeApi.as_view(),
|
||||
name='user-node-children-with-assets-as-tree'),
|
||||
|
||||
path('<str:user>/nodes/children-with-k8s/tree/',
|
||||
api.UserGrantedK8sAsTreeApi.as_view(),
|
||||
name='user-nodes-children-with-k8s-as-tree'),
|
||||
|
||||
# 同步树
|
||||
path('<str:user>/nodes-with-assets/tree/', api.UserPermedNodesWithAssetsAsTreeApi.as_view(),
|
||||
name='user-nodes-with-assets-as-tree'),
|
||||
# accounts
|
||||
|
|
|
@ -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() \
|
||||
|
|
Loading…
Reference in New Issue