Commit ee97144a authored by jym503558564's avatar jym503558564

[Bugfix] 修复资产授权列表 节点搜索报500错误

parent 01ead7c8
...@@ -68,15 +68,18 @@ class AssetPermissionViewSet(viewsets.ModelViewSet): ...@@ -68,15 +68,18 @@ class AssetPermissionViewSet(viewsets.ModelViewSet):
node_id = self.request.query_params.get('node_id') node_id = self.request.query_params.get('node_id')
node_name = self.request.query_params.get('node') node_name = self.request.query_params.get('node')
if node_id: if node_id:
node = get_object_or_none(Node, pk=node_id) nodes = Node.objects.filter(pk=node_id)
elif node_name: elif node_name:
node = get_object_or_none(Node, name=node_name) nodes = Node.objects.filter(value=node_name)
else: else:
return queryset return queryset
if not node: if not nodes:
return queryset.none() return queryset.none()
nodes = node.get_ancestors(with_self=True)
queryset = queryset.filter(nodes__in=nodes) related_nodes = []
for node in nodes:
[related_nodes.append(item) for item in node.get_ancestors(with_self=True)]
queryset = queryset.filter(nodes__in=related_nodes)
return queryset return queryset
def filter_asset(self, queryset): def filter_asset(self, queryset):
......
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