diff --git a/app/api/views/user.py b/app/api/views/user.py index 2100ed5f..9767a007 100644 --- a/app/api/views/user.py +++ b/app/api/views/user.py @@ -1,4 +1,6 @@ from django.contrib.auth.models import User +from django_filters.rest_framework import DjangoFilterBackend +from rest_framework import generics, filters from rest_framework.permissions import IsAuthenticated from rest_framework.response import Response from rest_framework.views import APIView @@ -15,10 +17,11 @@ class Me(APIView): return Response(serializer.data) -class Users(APIView): +class Users(generics.ListAPIView): + queryset = User.objects.all() + serializer_class = UserSerializer permission_classes = [IsAuthenticated & IsProjectAdmin] + pagination_class = None + filter_backends = (DjangoFilterBackend, filters.SearchFilter) + search_fields = ('username',) - def get(self, request, *args, **kwargs): - queryset = User.objects.all() - serialized_data = UserSerializer(queryset, many=True).data - return Response(serialized_data)