Commit 5c002e91 authored by BaiJiangJie's avatar BaiJiangJie

[Update] 修改获取资产distinct

parent 41a88310
...@@ -53,14 +53,14 @@ class AssetViewSet(IDInFilterMixin, LabelFilter, BulkModelViewSet): ...@@ -53,14 +53,14 @@ class AssetViewSet(IDInFilterMixin, LabelFilter, BulkModelViewSet):
if show_current_asset: if show_current_asset:
self.queryset = self.queryset.filter( self.queryset = self.queryset.filter(
Q(nodes=node_id) | Q(nodes__isnull=True) Q(nodes=node_id) | Q(nodes__isnull=True)
).distinct() )
return return
if show_current_asset: if show_current_asset:
self.queryset = self.queryset.filter(nodes=node).distinct() self.queryset = self.queryset.filter(nodes=node)
else: else:
self.queryset = self.queryset.filter( self.queryset = self.queryset.filter(
nodes__key__regex='^{}(:[0-9]+)*$'.format(node.key), nodes__key__regex='^{}(:[0-9]+)*$'.format(node.key),
).distinct() )
def filter_admin_user_id(self): def filter_admin_user_id(self):
admin_user_id = self.request.query_params.get('admin_user_id') admin_user_id = self.request.query_params.get('admin_user_id')
......
...@@ -124,7 +124,7 @@ class Node(OrgModelMixin): ...@@ -124,7 +124,7 @@ class Node(OrgModelMixin):
assets = Asset.objects.filter(Q(nodes__id=self.id) | Q(nodes__isnull=True)) assets = Asset.objects.filter(Q(nodes__id=self.id) | Q(nodes__isnull=True))
else: else:
assets = Asset.objects.filter(nodes__id=self.id) assets = Asset.objects.filter(nodes__id=self.id)
return assets return assets.distinct()
def get_valid_assets(self): def get_valid_assets(self):
return self.get_assets().valid() return self.get_assets().valid()
......
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