Compare commits

...

2 commits

2 changed files with 9 additions and 2 deletions

View file

@ -19,7 +19,7 @@ class IsPlanning(BasePermission):
"""
def has_permission(self, request, view):
return bool(request.user and request.user.role in ("planning", "admin"))
return bool(request.user and request.user.role in ("planning", "admin", "head", "staff"))
class IsHead(BasePermission):

View file

@ -15,7 +15,14 @@ class QuestionnaireListAPIView(generics.ListAPIView):
serializer_class = QuestionnaireSerializer
queryset = Questionnaire.objects.all()
pagination_class = PageNumberPagination
permission_classes = [IsAuthenticated, IsPlanning]
permission_classes = [IsAuthenticated]
def get_queryset(self):
user = self.request.user
if user.role == "client":
return Questionnaire.objects.filter(client=user)
else:
return Questionnaire.objects.all()
class QuestionnaireSubmitView(generics.CreateAPIView):