mirror of https://github.com/doccano/doccano.git
pythonannotation-tooldatasetsactive-learningtext-annotationdatasetnatural-language-processingdata-labelingmachine-learning
You can not select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
26 lines
910 B
26 lines
910 B
from django.contrib.auth.models import User
|
|
from django_filters.rest_framework import DjangoFilterBackend
|
|
from rest_framework import filters, generics
|
|
from rest_framework.permissions import IsAuthenticated
|
|
from rest_framework.response import Response
|
|
from rest_framework.views import APIView
|
|
|
|
from .serializers import UserSerializer
|
|
from projects.permissions import IsProjectAdmin
|
|
|
|
|
|
class Me(APIView):
|
|
permission_classes = (IsAuthenticated,)
|
|
|
|
def get(self, request, *args, **kwargs):
|
|
serializer = UserSerializer(request.user, context={"request": request})
|
|
return Response(serializer.data)
|
|
|
|
|
|
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",)
|