From 5aa6a94710ae960b4079db9069a12466e827aeb6 Mon Sep 17 00:00:00 2001 From: beeankha Date: Thu, 19 Sep 2019 11:12:19 -0400 Subject: [PATCH] Enable approval notifications to show up at... ...workflow jobs notifications endpoint --- awx/api/generics.py | 5 ++++- awx/api/views/__init__.py | 5 +++++ 2 files changed, 9 insertions(+), 1 deletion(-) diff --git a/awx/api/generics.py b/awx/api/generics.py index 06f80887ae..be58b057d8 100644 --- a/awx/api/generics.py +++ b/awx/api/generics.py @@ -489,9 +489,12 @@ class SubListAPIView(ParentMixin, ListAPIView): parent = self.get_parent_object() self.check_parent_access(parent) qs = self.request.user.get_queryset(self.model).distinct() - sublist_qs = getattrd(parent, self.relationship).distinct() + sublist_qs = self.get_sublist_queryset(parent) return qs & sublist_qs + def get_sublist_queryset(self, parent): + return getattrd(parent, self.relationship).distinct() + class DestroyAPIView(generics.DestroyAPIView): diff --git a/awx/api/views/__init__.py b/awx/api/views/__init__.py index 90253c448f..7b831edfa5 100644 --- a/awx/api/views/__init__.py +++ b/awx/api/views/__init__.py @@ -3379,6 +3379,11 @@ class WorkflowJobNotificationsList(SubListAPIView): relationship = 'notifications' search_fields = ('subject', 'notification_type', 'body',) + def get_sublist_queryset(self, parent): + return self.model.objects.filter(Q(unifiedjob_notifications=parent) | + Q(unifiedjob_notifications__unified_job_node__workflow_job=parent, + unifiedjob_notifications__workflowapproval__isnull=False)).distinct() + class WorkflowJobActivityStreamList(SubListAPIView):