Skip to content

Commit

Permalink
Merge pull request #313 from fasrc/development
Browse files Browse the repository at this point in the history
change user value for api projectusers call to username
  • Loading branch information
claire-peters authored Aug 2, 2024
2 parents 23b2242 + 4fa8e0b commit 4eeb8de
Show file tree
Hide file tree
Showing 2 changed files with 5 additions and 5 deletions.
6 changes: 3 additions & 3 deletions coldfront/plugins/api/serializers.py
Original file line number Diff line number Diff line change
Expand Up @@ -188,7 +188,7 @@ class Meta:


class ProjectUserSerializer(serializers.ModelSerializer):
user = serializers.SlugRelatedField(slug_field='full_name', read_only=True)
user = serializers.SlugRelatedField(slug_field='username', read_only=True)
status = serializers.SlugRelatedField(slug_field='name', read_only=True)
role = serializers.SlugRelatedField(slug_field='name', read_only=True)

Expand All @@ -209,12 +209,12 @@ class Meta:

def get_project_users(self, obj):
request = self.context.get('request', None)
if request and request.query_params.get('project_users') == 'true':
if request and request.query_params.get('project_users') in ['true','True']:
return ProjectUserSerializer(obj.projectuser_set, many=True, read_only=True).data
return None

def get_allocations(self, obj):
request = self.context.get('request', None)
if request and request.query_params.get('allocations') == 'true':
if request and request.query_params.get('allocations') in ['true','True']:
return ProjAllocationSerializer(obj.allocation_set, many=True, read_only=True).data
return None
4 changes: 2 additions & 2 deletions coldfront/plugins/api/views.py
Original file line number Diff line number Diff line change
Expand Up @@ -251,7 +251,7 @@ class ProjectViewSet(viewsets.ReadOnlyModelViewSet):
Query parameters:
- allocations (default false)
Show related allocation data.
- users (default false)
- project_users (default false)
Show related user data.
'''
serializer_class = serializers.ProjectSerializer
Expand All @@ -275,7 +275,7 @@ def get_queryset(self):
)
).distinct().order_by('pi')

if self.request.query_params.get('users') in ['True', 'true']:
if self.request.query_params.get('project_users') in ['True', 'true']:
projects = projects.prefetch_related('projectuser_set')

if self.request.query_params.get('allocations') in ['True', 'true']:
Expand Down

0 comments on commit 4eeb8de

Please sign in to comment.