UPDATE
This commit is contained in:
@@ -1,4 +1,3 @@
|
||||
import requests
|
||||
from django.db.models import Q
|
||||
from django.shortcuts import get_object_or_404
|
||||
from django_core.mixins import BaseViewSetMixin
|
||||
@@ -14,7 +13,6 @@ from rest_framework.viewsets import ModelViewSet
|
||||
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 AutoEvaluationSerializer
|
||||
from core.apps.evaluation.serializers.auto import (
|
||||
CreateAutoevaluationSerializer,
|
||||
ListAutoevaluationSerializer,
|
||||
@@ -159,32 +157,8 @@ class AutoEvaluationListAppraisersView(GenericAPIView):
|
||||
return Response({"error": str(e)}, status=500)
|
||||
|
||||
|
||||
@extend_schema(
|
||||
tags=["AutoEvaluation"],
|
||||
request=AutoEvaluationSerializer,
|
||||
)
|
||||
class AutoEvaluationRequestView(APIView):
|
||||
authentication_classes = []
|
||||
permission_classes = [AllowAny]
|
||||
|
||||
def post(self, request):
|
||||
serializer = AutoEvaluationSerializer(data=request.data)
|
||||
|
||||
if serializer.is_valid():
|
||||
data = serializer.validated_data
|
||||
url = "https://uzxarid.felixits.uz/api/v1/ad/price-estimate/"
|
||||
response = requests.post(url, json=data)
|
||||
|
||||
return Response({
|
||||
"success": True,
|
||||
"external_status": response.status_code,
|
||||
"data": response.json(),
|
||||
})
|
||||
return Response({"error": serializer.errors}, status=400)
|
||||
|
||||
|
||||
@extend_schema(tags=["AutoEvaluation"])
|
||||
class GetArchivedEvaluation(ListAPIView):
|
||||
class GetArchivedEvaluationListAPIView(ListAPIView):
|
||||
authentication_classes = []
|
||||
permission_classes = [IsAuthenticated]
|
||||
|
||||
@@ -192,4 +166,13 @@ class GetArchivedEvaluation(ListAPIView):
|
||||
return AutoEvaluationModel.objects.filter(is_archived=True)
|
||||
|
||||
|
||||
@extend_schema(tags=["AutoEvaluation"])
|
||||
class ArchivedEvaluation(APIView):
|
||||
authentication_classes = []
|
||||
permission_classes = [IsAuthenticated]
|
||||
|
||||
def post(self, request, pk):
|
||||
auto_evaluation = get_object_or_404(AutoEvaluationModel, pk=pk)
|
||||
auto_evaluation.is_archived = request.data["is_archived"]
|
||||
auto_evaluation.save()
|
||||
return Response({"success": True}, status=200)
|
||||
|
||||
Reference in New Issue
Block a user