From 9d289e4349b3750d7a323d9b99286c5d5d182d79 Mon Sep 17 00:00:00 2001 From: Matthew Jones Date: Tue, 3 Jan 2017 15:31:11 -0500 Subject: [PATCH] Fix some issues related to purging the old paging decorator --- awx/api/views.py | 16 ++++++---------- 1 file changed, 6 insertions(+), 10 deletions(-) diff --git a/awx/api/views.py b/awx/api/views.py index e15084a681..de81c451cd 100644 --- a/awx/api/views.py +++ b/awx/api/views.py @@ -3446,7 +3446,7 @@ class JobJobPlaysList(BaseJobEventsList): all_plays = [] job = Job.objects.filter(pk=self.kwargs['pk']) if not job.exists(): - return ({'detail': 'Job not found.'}, -1, status.HTTP_404_NOT_FOUND) + return Response({'detail': 'Job not found.'}, status.HTTP_404_NOT_FOUND) job = job[0] # Put together a queryset for relevant job events. @@ -3503,9 +3503,7 @@ class JobJobPlaysList(BaseJobEventsList): play_details['skipped_count'] = skipped_count play_details['unreachable_count'] = unreachable_count all_plays.append(play_details) - - # Done; return the plays and the total count. - return all_plays, count, None + return Response(dict(count=count, plays=all_plays)) class JobJobTasksList(BaseJobEventsList): @@ -3529,15 +3527,15 @@ class JobJobTasksList(BaseJobEventsList): # If there's no event ID specified, this will return a 404. job = Job.objects.filter(pk=self.kwargs['pk']) if not job.exists(): - return ({'detail': _('Job not found.')}, -1, status.HTTP_404_NOT_FOUND) + return Response({'detail': _('Job not found.')}, status=status.HTTP_404_NOT_FOUND) job = job[0] if 'event_id' not in request.query_params: - return ({"detail": _("'event_id' not provided.")}, -1, status.HTTP_400_BAD_REQUEST) + return Response({"detail": _("'event_id' not provided.")}, status.HTTP_400_BAD_REQUEST) parent_task = job.job_events.filter(pk=int(request.query_params.get('event_id', -1))) if not parent_task.exists(): - return ({'detail': _('Parent event not found.')}, -1, status.HTTP_404_NOT_FOUND) + return Response({'detail': _('Parent event not found.')}, status.HTTP_404_NOT_FOUND) parent_task = parent_task[0] STARTING_EVENTS = ('playbook_on_task_start', 'playbook_on_setup') @@ -3628,9 +3626,7 @@ class JobJobTasksList(BaseJobEventsList): task_data['host_count'] += child_data['num'] count += 1 results.append(task_data) - - # Done; return the results and count. - return (results, count, None) + return Response(dict(count=count, tasks=results)) class AdHocCommandList(ListCreateAPIView):