populate event children list via parent_uuid

This commit is contained in:
AlanCoding
2019-05-01 11:55:53 -04:00
parent aaeb2d6fb9
commit 530a7ba51d
3 changed files with 8 additions and 3 deletions

View File

@@ -4124,8 +4124,7 @@ class JobEventSerializer(BaseSerializer):
))
if obj.parent_id:
res['parent'] = self.reverse('api:job_event_detail', kwargs={'pk': obj.parent_id})
if obj.children.exists():
res['children'] = self.reverse('api:job_event_children_list', kwargs={'pk': obj.pk})
res['children'] = self.reverse('api:job_event_children_list', kwargs={'pk': obj.pk})
if obj.host_id:
res['host'] = self.reverse('api:host_detail', kwargs={'pk': obj.host_id})
if obj.hosts.exists():

View File

@@ -3864,6 +3864,12 @@ class JobEventChildrenList(SubListAPIView):
view_name = _('Job Event Children List')
search_fields = ('stdout',)
def get_queryset(self):
parent_event = self.get_parent_object()
self.check_parent_access(parent_event)
qs = self.request.user.get_queryset(self.model).filter(parent_uuid=parent_event.uuid)
return qs
class JobEventHostsList(HostRelatedSearchMixin, SubListAPIView):

View File

@@ -2264,7 +2264,7 @@ class JobEventAccess(BaseAccess):
'''
model = JobEvent
prefetch_related = ('hosts', 'children', 'job__job_template', 'host',)
prefetch_related = ('hosts', 'job__job_template', 'host',)
def filtered_queryset(self):
return self.model.objects.filter(