2024-11-24 10:34:41 +08:00
|
|
|
from rest_framework import generics
|
|
|
|
from .serializers import QuestionnaireSerializer
|
|
|
|
from rest_framework.permissions import IsAuthenticated
|
|
|
|
from .models import Questionnaire
|
|
|
|
from rest_framework.pagination import PageNumberPagination
|
2024-12-04 01:29:30 +08:00
|
|
|
from accounts.permissions import IsStaff, IsPlanning
|
2024-11-24 02:56:36 +08:00
|
|
|
|
2024-11-24 10:34:41 +08:00
|
|
|
|
|
|
|
class QuestionnaireListAPIView(generics.ListAPIView):
|
|
|
|
"""
|
|
|
|
Used by staff to view questionnaires
|
|
|
|
"""
|
|
|
|
|
|
|
|
http_method_names = ["get"]
|
|
|
|
serializer_class = QuestionnaireSerializer
|
|
|
|
queryset = Questionnaire.objects.all()
|
|
|
|
pagination_class = PageNumberPagination
|
2024-12-04 01:29:30 +08:00
|
|
|
permission_classes = [IsAuthenticated, IsPlanning]
|
2024-11-24 10:34:41 +08:00
|
|
|
|
|
|
|
|
|
|
|
class QuestionnaireSubmitView(generics.CreateAPIView):
|
|
|
|
"""
|
|
|
|
Used by clients to submit questionnaires
|
|
|
|
"""
|
|
|
|
|
|
|
|
http_method_names = ["post"]
|
|
|
|
serializer_class = QuestionnaireSerializer
|
|
|
|
permission_classes = [IsAuthenticated]
|