Skip to content

Commit

Permalink
feat: Update UsersByTagViewSet to include wikimedia_project tag type
Browse files Browse the repository at this point in the history
  • Loading branch information
albertoleoncio committed Jul 3, 2024
1 parent 297355e commit ff10ec3
Showing 1 changed file with 3 additions and 3 deletions.
6 changes: 3 additions & 3 deletions users/views.py
Original file line number Diff line number Diff line change
Expand Up @@ -98,7 +98,7 @@ def list(self, request, *args, **kwargs):
return Response(response, status=status.HTTP_400_BAD_REQUEST)


# Class to list users by "tags" (skills, languages, territories, projects, affiliation) with format /tags/<tag_type>/<tag_id>/
# Class to list users by "tags" (skills, languages, territories, wikimedia_project, affiliation) with format /tags/<tag_type>/<tag_id>/
# Example: /tags/project/1/
class UsersByTagViewSet(viewsets.ReadOnlyModelViewSet):
queryset = Profile.objects.all()
Expand Down Expand Up @@ -127,7 +127,7 @@ def retrieve(self, request, *args, **kwargs):
elif tag_type == 'territory':
users = Profile.objects.filter(territory=tag_id)
data = [{'id': user.id, 'display_name': user.display_name, 'username': user.user.username, 'profile_image': user.profile_image} for user in users]
elif tag_type == 'project':
elif tag_type == 'wikimedia_project':
users = Profile.objects.filter(wikimedia_project=tag_id)
data = [{'id': user.id, 'display_name': user.display_name, 'username': user.user.username, 'profile_image': user.profile_image} for user in users]
elif tag_type == 'affiliation':
Expand All @@ -140,5 +140,5 @@ def retrieve(self, request, *args, **kwargs):
return Response(data)

def list(self, request, *args, **kwargs):
response = {'message': 'Please provide a tag type and a tag id. Options are: skill, language, territory, project, affiliation.'}
response = {'message': 'Please provide a tag type and a tag id. Options are: skill, language, territory, wikimedia_project, affiliation.'}
return Response(response, status=status.HTTP_400_BAD_REQUEST)

0 comments on commit ff10ec3

Please sign in to comment.