|
|
@ -50,16 +50,18 @@ class AssetViewSet(IDInFilterMixin, LabelFilter, BulkModelViewSet):
|
|
|
|
queryset = queryset.filter(admin_user=admin_user)
|
|
|
|
queryset = queryset.filter(admin_user=admin_user)
|
|
|
|
|
|
|
|
|
|
|
|
if node_id and show_current_asset:
|
|
|
|
if node_id and show_current_asset:
|
|
|
|
|
|
|
|
node = get_object_or_404(Node, id=node_id)
|
|
|
|
|
|
|
|
if node.is_root():
|
|
|
|
queryset = queryset.filter(
|
|
|
|
queryset = queryset.filter(
|
|
|
|
Q(nodes=node_id) | Q(nodes__isnull=True)
|
|
|
|
Q(nodes=node_id) | Q(nodes__isnull=True)
|
|
|
|
).distinct()
|
|
|
|
).distinct()
|
|
|
|
|
|
|
|
else:
|
|
|
|
|
|
|
|
queryset = queryset.filter(nodes=node).distinct()
|
|
|
|
|
|
|
|
|
|
|
|
if node_id and not show_current_asset:
|
|
|
|
if node_id and not show_current_asset:
|
|
|
|
node = get_object_or_404(Node, id=node_id)
|
|
|
|
node = get_object_or_404(Node, id=node_id)
|
|
|
|
if not node.is_root():
|
|
|
|
if node.is_root():
|
|
|
|
queryset = queryset.filter(
|
|
|
|
queryset = Asset.objects.all()
|
|
|
|
Q(nodes__key__regex='^{}(:[0-9]+)*$'.format(node.key)) |
|
|
|
|
|
|
|
|
Q(nodes__isnull=True),
|
|
|
|
|
|
|
|
).distinct()
|
|
|
|
|
|
|
|
else:
|
|
|
|
else:
|
|
|
|
queryset = queryset.filter(
|
|
|
|
queryset = queryset.filter(
|
|
|
|
nodes__key__regex='^{}(:[0-9]+)*$'.format(node.key),
|
|
|
|
nodes__key__regex='^{}(:[0-9]+)*$'.format(node.key),
|
|
|
|