2025-01-16 19:54:49 +08:00
|
|
|
from rest_framework import generics
|
2025-01-17 11:39:00 +08:00
|
|
|
from .serializers import CustomUserSerializer, CustomUserUpdateSerializer
|
2025-01-16 19:54:49 +08:00
|
|
|
from rest_framework.permissions import IsAuthenticated
|
|
|
|
from accounts.permissions import IsAdmin
|
|
|
|
from .models import CustomUser
|
|
|
|
|
|
|
|
|
|
|
|
class CustomUserDeleteView(generics.DestroyAPIView):
|
|
|
|
"""
|
|
|
|
Used by admin to delete users. Accepts the user id as a URL parameter
|
|
|
|
"""
|
|
|
|
|
|
|
|
http_method_names = ["delete"]
|
|
|
|
serializer_class = CustomUserSerializer
|
|
|
|
queryset = CustomUser.objects.all()
|
|
|
|
permission_classes = [IsAuthenticated, IsAdmin]
|
2025-01-17 11:39:00 +08:00
|
|
|
|
|
|
|
|
|
|
|
class CustomUserUpdateView(generics.UpdateAPIView):
|
|
|
|
"""
|
|
|
|
Used by staff to upload documents.
|
|
|
|
"""
|
|
|
|
|
|
|
|
http_method_names = ["patch"]
|
|
|
|
serializer_class = CustomUserUpdateSerializer
|
|
|
|
queryset = CustomUser.objects.all()
|
|
|
|
permission_classes = [IsAuthenticated, IsAdmin]
|