From 530a7ba51d7371f3073f854b9ef123ad894fd92c Mon Sep 17 00:00:00 2001 From: AlanCoding Date: Wed, 1 May 2019 11:55:53 -0400 Subject: [PATCH] populate event children list via parent_uuid --- awx/api/serializers.py | 3 +-- awx/api/views/__init__.py | 6 ++++++ awx/main/access.py | 2 +- 3 files changed, 8 insertions(+), 3 deletions(-) diff --git a/awx/api/serializers.py b/awx/api/serializers.py index 7c353a9ba5..588392bec4 100644 --- a/awx/api/serializers.py +++ b/awx/api/serializers.py @@ -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(): diff --git a/awx/api/views/__init__.py b/awx/api/views/__init__.py index c0554440a9..9fc6d730e6 100644 --- a/awx/api/views/__init__.py +++ b/awx/api/views/__init__.py @@ -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): diff --git a/awx/main/access.py b/awx/main/access.py index 6d615e8677..9e840f1f81 100644 --- a/awx/main/access.py +++ b/awx/main/access.py @@ -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(