2023-03-21 21:22:14 +08:00
|
|
|
from rest_framework.permissions import IsAuthenticated
|
2023-04-22 00:54:00 +08:00
|
|
|
from rest_framework import viewsets, generics
|
2023-03-21 21:22:14 +08:00
|
|
|
from .serializers import SubjectSerializer
|
|
|
|
from .models import Subject
|
|
|
|
|
|
|
|
|
|
|
|
class SubjectViewSet(viewsets.ModelViewSet):
|
|
|
|
# permission_classes = [IsAuthenticated]
|
|
|
|
serializer_class = SubjectSerializer
|
|
|
|
queryset = Subject.objects.all().order_by('-year_level')
|
2023-04-22 00:54:00 +08:00
|
|
|
|
|
|
|
|
|
|
|
class FirstYearSubjectViewSet(generics.ListAPIView):
|
|
|
|
# permission_classes = [IsAuthenticated]
|
|
|
|
serializer_class = SubjectSerializer
|
|
|
|
queryset = Subject.objects.filter(year_level='1st Year')
|
|
|
|
|
|
|
|
|
|
|
|
class SecondYearSubjectViewSet(generics.ListAPIView):
|
|
|
|
# permission_classes = [IsAuthenticated]
|
|
|
|
serializer_class = SubjectSerializer
|
|
|
|
queryset = Subject.objects.filter(year_level='2nd Year')
|
|
|
|
|
|
|
|
|
|
|
|
class ThirdYearSubjectViewSet(generics.ListAPIView):
|
|
|
|
# permission_classes = [IsAuthenticated]
|
|
|
|
serializer_class = SubjectSerializer
|
|
|
|
queryset = Subject.objects.filter(year_level='3rd Year')
|
|
|
|
|
|
|
|
|
|
|
|
class FourthYearSubjectViewSet(generics.ListAPIView):
|
|
|
|
# permission_classes = [IsAuthenticated]
|
|
|
|
serializer_class = SubjectSerializer
|
|
|
|
queryset = Subject.objects.filter(year_level='4th Year')
|