Skip to content

Commit

Permalink
Return task_messages for import tasks list API
Browse files Browse the repository at this point in the history
Return task_messages list for import tasks list API endpoint
if request has `id` parameter. This is required for compatibility
with legacy `ansible-galaxy` client.
  • Loading branch information
cutwater committed Nov 27, 2018
1 parent c2564cb commit 84467db
Showing 1 changed file with 9 additions and 0 deletions.
9 changes: 9 additions & 0 deletions galaxy/api/views/views.py
Original file line number Diff line number Diff line change
Expand Up @@ -368,9 +368,16 @@ def get_queryset(self):
)
return qs

def get_serializer_class(self):
# NOTE(cutwater): This is for compatibility with ansible-galaxy client.
if 'id' in self.request.GET:
return serializers.ImportTaskDetailSerializer
return super(ImportTaskList, self).get_serializer_class()

def list(self, request, *args, **kwargs):
github_user = request.GET.get('github_user')
github_repo = request.GET.get('github_repo')

qs = self.get_queryset()
if github_user and github_repo:
# Support ansible-galaxy <= 2.6
Expand All @@ -380,9 +387,11 @@ def list(self, request, *args, **kwargs):
else:
qs = self.filter_queryset(qs)
page = self.paginate_queryset(qs)

if page is not None:
serializer = self.get_serializer(page, many=True)
return self.get_paginated_response(serializer.data)

serializer = self.get_serializer(qs, many=True)
return Response(serializer.data)

Expand Down

0 comments on commit 84467db

Please sign in to comment.