mirror of
https://github.com/lemeow125/StudE-Backend.git
synced 2024-11-17 06:19:24 +08:00
22 lines
735 B
Python
22 lines
735 B
Python
from rest_framework import generics
|
|
from rest_framework.permissions import IsAuthenticated
|
|
from .models import StudentStatus
|
|
from .serializers import StudentStatusSerializer
|
|
|
|
|
|
class StudentStatusAPIView(generics.RetrieveUpdateDestroyAPIView):
|
|
serializer_class = StudentStatusSerializer
|
|
permission_classes = [IsAuthenticated]
|
|
|
|
def get_object(self):
|
|
user = self.request.user
|
|
return StudentStatus.objects.get(user=user)
|
|
|
|
|
|
class ActiveStudentStatusListAPIView(generics.ListAPIView):
|
|
serializer_class = StudentStatusSerializer
|
|
permission_classes = [IsAuthenticated]
|
|
|
|
def get_queryset(self):
|
|
user = self.request.user
|
|
return StudentStatus.objects.filter(active=True).exclude(user=user)
|