Unverified Commit a978bf99 authored by BaiJiangJie's avatar BaiJiangJie Committed by GitHub

Merge pull request #3342 from jumpserver/perms_assets_search_bug

[Bugfix] 修复资产授权列表搜索 【node:node_name】/【node_id:node_id】/【is_valid:false】 出现500错误
parents 491f5902 70664d43
......@@ -73,14 +73,17 @@ class AssetPermissionViewSet(OrgModelViewSet):
node_id = self.request.query_params.get('node_id')
node_name = self.request.query_params.get('node')
if node_id:
node = get_object_or_none(Node, pk=node_id)
_nodes = Node.objects.filter(pk=node_id)
elif node_name:
node = get_object_or_none(Node, name=node_name)
_nodes = Node.objects.filter(value=node_name)
else:
return queryset
if not node:
if not _nodes:
return queryset.none()
nodes = node.get_ancestors(with_self=True)
nodes = set()
for node in _nodes:
nodes |= set(node.get_ancestors(with_self=True))
queryset = queryset.filter(nodes__in=nodes)
return queryset
......
......@@ -29,7 +29,7 @@ class BasePermissionQuerySet(models.QuerySet):
return self.filter(is_active=False)
def invalid(self):
now = timezone.now
now = timezone.now()
q = (
Q(is_active=False) |
Q(date_start__gt=now) |
......
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