StudE-Backend/stude/student_status/views.py

23 lines
719 B
Python
Raw Permalink Normal View History

2023-06-27 13:40:31 +08:00
from rest_framework import generics, viewsets
from rest_framework.permissions import IsAuthenticated
from .models import StudentStatus
from .serializers import StudentStatusSerializer
2023-06-27 13:40:31 +08:00
class StudentStatusAPIView(generics.RetrieveUpdateAPIView):
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
2023-07-09 19:18:21 +08:00
permission_classes = [IsAuthenticated]
def get_queryset(self):
user = self.request.user
2023-07-09 19:07:33 +08:00
return StudentStatus.objects.filter(active=True)