This commit is contained in:
Shaxobff
2026-04-27 11:57:27 +05:00
parent e560fdaf2d
commit 81a4287db1
3 changed files with 45 additions and 18 deletions

View File

@@ -30,8 +30,9 @@ from .views import (
TechPassportAPIView,
EvaluationStatusChange,
CertificateView,
ArchiveEvaluationrequestView, GetArchivedEvaluationListAPIView, ArchivedEvaluation,
GetArchivedQuickevaluationListAPIView, ChangeQuickevaluationAPIView,
ArchiveEvaluationrequestView, GetArchivedAutoEvaluationListAPIView, ArchivedAutoEvaluation,
GetArchivedQuickevaluationListAPIView, ChangeQuickevaluationAPIView, ArchivedReqEvaluation,
GetArchivedReqEvaluationListAPIView,
)
router = DefaultRouter()
@@ -83,10 +84,16 @@ urlpatterns = [
path("archive/evaluation-request/", ArchiveEvaluationrequestView.as_view(), name="evaluation-request-archive"),
path("archived-evaluvation/", GetArchivedEvaluationListAPIView.as_view(),
path("archived-evaluvation/", GetArchivedAutoEvaluationListAPIView.as_view(),
name="archived-evaluation"),
path("auto-evaluvation-change-status/<int:pk>", ArchivedEvaluation.as_view(),
path("auto-evaluvation-change-status/<int:pk>", ArchivedAutoEvaluation.as_view(),
name="archived-evaluation"),
path("req-evaluvation-change-status/<int:pk>", ArchivedReqEvaluation.as_view(),
name="archived-req-evaluation"),
path("req-evaluvation-change-status/", GetArchivedReqEvaluationListAPIView.as_view(),
name="archived-req-evaluation"),
]

View File

@@ -158,14 +158,14 @@ class AutoEvaluationListAppraisersView(GenericAPIView):
@extend_schema(tags=["AutoEvaluation"])
class GetArchivedEvaluationListAPIView(ListAPIView):
class GetArchivedAutoEvaluationListAPIView(ListAPIView):
permission_classes = [IsAuthenticated]
def get_queryset(self):
return AutoEvaluationModel.objects.filter(is_archived=True)
@extend_schema(tags=["AutoEvaluation"])
class ArchivedEvaluation(APIView):
class ArchivedAutoEvaluation(APIView):
permission_classes = [IsAuthenticated]
def post(self, request, pk):

View File

@@ -1,16 +1,18 @@
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 OpenApiResponse
from drf_spectacular.utils import extend_schema
from rest_framework import status
from rest_framework.filters import OrderingFilter, SearchFilter
from rest_framework.pagination import PageNumberPagination
from rest_framework.permissions import AllowAny, IsAuthenticated
from rest_framework.viewsets import ModelViewSet
from rest_framework.generics import GenericAPIView, ListAPIView
from rest_framework.permissions import IsAuthenticated
from rest_framework.response import Response
from rest_framework.views import APIView
from rest_framework import status
from rest_framework.viewsets import ModelViewSet
from core.apps.accounts.choices import RoleChoice
from core.apps.evaluation.choices.request import RequestStatus
from core.apps.evaluation.filters.request import EvaluationrequestFilter
from core.apps.evaluation.models import EvaluationrequestModel
from core.apps.evaluation.serializers.request import (
@@ -19,9 +21,6 @@ from core.apps.evaluation.serializers.request import (
RetrieveEvaluationrequestSerializer,
ArchiveEvaluationrequestSerializer,
)
from core.apps.evaluation.choices.request import RequestStatus
from rest_framework.generics import GenericAPIView
from drf_spectacular.utils import OpenApiResponse
# class RequestPagination(PageNumberPagination):
@@ -85,7 +84,6 @@ class EvaluationrequestView(BaseViewSetMixin, ModelViewSet):
).order_by("-created_at")
@extend_schema(tags=["EvaluationRequest"])
class AdminEvaluationrequestView(BaseViewSetMixin, ModelViewSet):
serializer_class = ListEvaluationrequestSerializer
@@ -133,7 +131,8 @@ class AdminEvaluationrequestView(BaseViewSetMixin, ModelViewSet):
}
def get_queryset(self):
return EvaluationrequestModel.objects.select_related("value_determined", "rate_goal", "property_rights", "form_ownership", "user").order_by("-created_at")
return EvaluationrequestModel.objects.select_related("value_determined", "rate_goal", "property_rights",
"form_ownership", "user").order_by("-created_at")
def serializer_context(self):
return self.serializer_class(context={"request": self.request})
@@ -149,7 +148,6 @@ class EvaluationStatusChange(APIView):
evaluation = get_object_or_404(EvaluationrequestModel, pk=pk)
status_value = request.data.get('status')
if not status_value:
return Response({'detail': 'Status is required'}, status=status.HTTP_400_BAD_REQUEST)
@@ -176,6 +174,7 @@ class EvaluationStatusChange(APIView):
'id': evaluation.pk
})
@extend_schema(tags=["EvaluationRequest"])
class ArchiveEvaluationrequestView(GenericAPIView):
permission_classes = [IsAuthenticated]
@@ -248,3 +247,24 @@ class ArchiveEvaluationrequestView(GenericAPIView):
},
status=status.HTTP_200_OK
)
@extend_schema(tags=["EvaluationRequest"])
class GetArchivedReqEvaluationListAPIView(ListAPIView):
permission_classes = [IsAuthenticated]
def get_queryset(self):
return EvaluationrequestModel.objects.filter(is_archived=True)
@extend_schema(tags=["EvaluationRequest"])
class ArchivedReqEvaluation(APIView):
permission_classes = [IsAuthenticated]
def post(self, request, pk):
req_evaluation = get_object_or_404(EvaluationrequestModel, pk=pk)
req_evaluation.is_archived = request.data["is_archived"]
req_evaluation.save()
return Response({"success": True,
"status": req_evaluation.status,
"id": req_evaluation.pk}, status=200)