Browse Source

fix: 修复异步加载luna资产授权树时根节点下资产没有返回的问题

pull/9239/head
Bai 2 years ago
parent
commit
3443b06a28
  1. 6
      apps/perms/api/user_permission/tree/node_with_asset.py
  2. 1
      apps/perms/utils/user_perm.py

6
apps/perms/api/user_permission/tree/node_with_asset.py

@ -102,6 +102,12 @@ class UserPermedNodeChildrenWithAssetsAsTreeApi(BaseUserNodeWithAssetAsTreeApi):
if not node_key:
nodes = query_node_util.get_top_level_nodes()
assets = Asset.objects.none()
# 获取根节点下的资产
for node in nodes:
if not node.key.isdigit():
continue
assets = query_asset_util.get_node_assets(key=node.key)
break
elif node_key == PermNode.UNGROUPED_NODE_KEY:
nodes = PermNode.objects.none()
assets = query_asset_util.get_ungroup_assets()

1
apps/perms/utils/user_perm.py

@ -150,6 +150,7 @@ class UserPermNodeUtil:
def get_top_level_nodes(self):
nodes = self.get_special_nodes()
# 获取组织下的根节点
real_nodes = self._get_indirect_perm_node_children(key='')
nodes.extend(real_nodes)
if len(real_nodes) == 1:

Loading…
Cancel
Save