mirror of
https://github.com/ansible/awx.git
synced 2026-02-24 22:46:01 -03:30
Ensure access_list returns a 404 when object is not found
This commit is contained in:
@@ -500,7 +500,7 @@ class ResourceAccessList(ListAPIView):
|
|||||||
def get_queryset(self):
|
def get_queryset(self):
|
||||||
self.object_id = self.kwargs['pk']
|
self.object_id = self.kwargs['pk']
|
||||||
resource_model = getattr(self, 'resource_model')
|
resource_model = getattr(self, 'resource_model')
|
||||||
obj = resource_model.objects.get(pk=self.object_id)
|
obj = get_object_or_404(resource_model, pk=self.object_id)
|
||||||
|
|
||||||
content_type = ContentType.objects.get_for_model(obj)
|
content_type = ContentType.objects.get_for_model(obj)
|
||||||
roles = set(Role.objects.filter(content_type=content_type, object_id=obj.id))
|
roles = set(Role.objects.filter(content_type=content_type, object_id=obj.id))
|
||||||
@@ -509,4 +509,3 @@ class ResourceAccessList(ListAPIView):
|
|||||||
for r in roles:
|
for r in roles:
|
||||||
ancestors.update(set(r.ancestors.all()))
|
ancestors.update(set(r.ancestors.all()))
|
||||||
return User.objects.filter(roles__in=list(ancestors))
|
return User.objects.filter(roles__in=list(ancestors))
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user