Unverified Commit 62758223 authored by 老广's avatar 老广 Committed by GitHub

Merge pull request #1268 from jumpserver/bufix_for_perm_tree

[Bugfix] 解决上次引入的bug
parents 59eb1f8e 5103dab7
......@@ -108,18 +108,18 @@ class NodeChildrenApi(mixins.ListModelMixin, generics.CreateAPIView):
return node
def get_queryset(self):
queryset = set()
queryset = []
query_all = self.request.query_params.get("all")
query_assets = self.request.query_params.get('assets')
node = self.get_object()
if node == Node.root():
queryset.add(node)
queryset.append(node)
if query_all:
children = node.get_all_children()
else:
children = node.get_children()
queryset.update(set(children))
queryset.extend(list(children))
if query_assets:
assets = node.get_assets()
for asset in assets:
......@@ -128,7 +128,7 @@ class NodeChildrenApi(mixins.ListModelMixin, generics.CreateAPIView):
node_fake.parent = node
node_fake.value = asset.hostname
node_fake.is_node = False
queryset.add(node_fake)
queryset.append(node_fake)
queryset = sorted(queryset, key=lambda x: x.is_node, reverse=True)
return queryset
......
......@@ -18,8 +18,7 @@ class NodeTMPSerializer(serializers.ModelSerializer):
class Meta:
model = Node
fields = ['id', 'key', 'value', 'parent', 'assets_amount',
'is_asset']
fields = ['id', 'key', 'value', 'parent', 'assets_amount', 'is_node']
list_serializer_class = BulkListSerializer
@staticmethod
......
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