Merge pull request #3800 from AlanCoding/event_children_list

Populate event children list via parent_uuid

Reviewed-by: https://github.com/softwarefactory-project-zuul[bot]
This commit is contained in:
softwarefactory-project-zuul[bot] 2019-05-02 00:37:03 +00:00 committed by GitHub
commit 5ab7f888f1
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
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(