diff --git a/awx/api/urls.py b/awx/api/urls.py index 5ea83c0729..f3abfae3fe 100644 --- a/awx/api/urls.py +++ b/awx/api/urls.py @@ -204,6 +204,7 @@ job_urls = patterns('awx.api.views', url(r'^(?P[0-9]+)/cancel/$', 'job_cancel'), url(r'^(?P[0-9]+)/relaunch/$', 'job_relaunch'), url(r'^(?P[0-9]+)/job_host_summaries/$', 'job_job_host_summaries_list'), + url(r'^(?P[0-9]+)/job_events/$', 'job_job_events_list'), url(r'^(?P[0-9]+)/activity_stream/$', 'job_activity_stream_list'), url(r'^(?P[0-9]+)/stdout/$', 'job_stdout'), url(r'^(?P[0-9]+)/notifications/$', 'job_notifications_list'), diff --git a/awx/api/views.py b/awx/api/views.py index 0c828701ae..692e3eebfe 100644 --- a/awx/api/views.py +++ b/awx/api/views.py @@ -3473,6 +3473,22 @@ class GroupJobEventsList(BaseJobEventsList): parent_model = Group +class JobJobEventsList(BaseJobEventsList): + + parent_model = Job + + def get_queryset(self): + job = self.get_parent_object() + self.check_parent_access(job) + qs = job.job_events.all() + qs = qs.select_related('host') + qs = qs.prefetch_related('hosts', 'children') + if self.request.user.is_superuser or self.request.user.is_system_auditor: + return qs.all() + host_qs = self.request.user.get_queryset(Host) + return qs.filter(Q(host__isnull=True) | Q(host__in=host_qs)) + + class AdHocCommandList(ListCreateAPIView): model = AdHocCommand