update
This commit is contained in:
@@ -1,10 +1,9 @@
|
||||
from django.db.models import Q
|
||||
from django.shortcuts import get_object_or_404
|
||||
from django_core.mixins import BaseViewSetMixin
|
||||
|
||||
from django_filters.rest_framework import DjangoFilterBackend
|
||||
from drf_spectacular.utils import extend_schema, OpenApiParameter
|
||||
|
||||
from rest_framework import generics
|
||||
from rest_framework.filters import OrderingFilter, SearchFilter
|
||||
from rest_framework.generics import GenericAPIView, ListAPIView
|
||||
from rest_framework.permissions import AllowAny, IsAuthenticated
|
||||
@@ -12,10 +11,12 @@ from rest_framework.response import Response
|
||||
from rest_framework.views import APIView
|
||||
from rest_framework.viewsets import ModelViewSet
|
||||
|
||||
from core.apps.accounts.choices import RoleChoice
|
||||
from core.apps.accounts.serializers.user import UserSerializer
|
||||
from core.apps.evaluation.filters.auto import AutoevaluationFilter
|
||||
from core.apps.evaluation.models import AutoEvaluationModel
|
||||
from core.apps.evaluation.serializers import auto as serializers
|
||||
from core.apps.evaluation.serializers import auto as serializers, AutoEvaluationModelSerializer
|
||||
|
||||
|
||||
@extend_schema(tags=["AutoEvaluation"])
|
||||
class AutoEvaluationView(BaseViewSetMixin, ModelViewSet):
|
||||
@@ -175,3 +176,16 @@ class AutoEvaluationArchiveAPIView(APIView):
|
||||
},
|
||||
status=200
|
||||
)
|
||||
|
||||
@extend_schema(tags=["AutoEvaluation"])
|
||||
class AdminEvaluationsAPIView(generics.GenericAPIView):
|
||||
permission_classes = [IsAuthenticated]
|
||||
|
||||
def get(self, request):
|
||||
if request.user.role != RoleChoice.ADMIN:
|
||||
return Response({'detail': 'Forbidden'}, status=403)
|
||||
auto_eval = AutoEvaluationModel.objects.filter(
|
||||
created_by=self.request.user
|
||||
).select_related('appraisers').distinct()
|
||||
serializer = AutoEvaluationModelSerializer(auto_eval, many=True)
|
||||
return Response(serializer.data)
|
||||
|
||||
Reference in New Issue
Block a user