DocManagerBackend/docmanager_backend/questionnaires/views.py

29 lines
863 B
Python
Raw Normal View History

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
from accounts.permissions import IsStaff, IsPlanning
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
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]