diff --git a/coldfront/plugins/api/serializers.py b/coldfront/plugins/api/serializers.py index 2f5cbb22e..dd4ee7b58 100644 --- a/coldfront/plugins/api/serializers.py +++ b/coldfront/plugins/api/serializers.py @@ -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) @@ -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 diff --git a/coldfront/plugins/api/views.py b/coldfront/plugins/api/views.py index 99ca6243c..5622a246a 100644 --- a/coldfront/plugins/api/views.py +++ b/coldfront/plugins/api/views.py @@ -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 @@ -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']: