Commit c9aab608 authored by ibuler's avatar ibuler

[Bugfix] 修复luna不显示多组织资产的问题

parent 641567be
...@@ -411,18 +411,22 @@ class UserGrantedNodeChildrenApi(ListAPIView): ...@@ -411,18 +411,22 @@ class UserGrantedNodeChildrenApi(ListAPIView):
util = AssetPermissionUtil(self.request.user) util = AssetPermissionUtil(self.request.user)
node_id = self.request.query_params.get('id') node_id = self.request.query_params.get('id')
nodes_granted = util.get_nodes_with_assets() nodes_granted = util.get_nodes_with_assets()
if nodes_granted: if not nodes_granted:
first_node = sorted(nodes_granted, reverse=True)[0]
else:
return [] return []
root_nodes = [node for node in nodes_granted.keys() if node.is_root()]
queryset = []
if node_id and node_id in [str(node.id) for node in nodes_granted]: if node_id and node_id in [str(node.id) for node in nodes_granted]:
node = [node for node in nodes_granted if str(node.id) == node_id][0] node = [node for node in nodes_granted if str(node.id) == node_id][0]
else: elif len(root_nodes) == 1:
node = first_node node = root_nodes[0]
queryset = []
if node == first_node:
node.assets_amount = len(nodes_granted[node]) node.assets_amount = len(nodes_granted[node])
queryset.append(node) queryset.append(node)
else:
for node in root_nodes:
node.assets_amount = len(nodes_granted[node])
queryset.append(node)
return queryset
children = [] children = []
for child in node.get_children(): for child in node.get_children():
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment