feat: avto va tezkor baholash uchun history bo'limi qo'shildi

This commit is contained in:
2026-04-02 15:53:09 +05:00
parent c4330fd6f7
commit 2492583f43
34 changed files with 1159 additions and 4 deletions

View File

@@ -1,6 +1,7 @@
from .auto import * # noqa
from .customer import * # noqa
from .document import * # noqa
from .history import * # noqa
from .movable import * # noqa
from .quick import * # noqa
from .real_estate import * # noqa

View File

@@ -0,0 +1,76 @@
from django_core.mixins import BaseViewSetMixin
from django_filters.rest_framework import DjangoFilterBackend
from drf_spectacular.utils import OpenApiParameter, extend_schema
from rest_framework.filters import OrderingFilter
from rest_framework.permissions import AllowAny
from rest_framework.viewsets import ReadOnlyModelViewSet
from core.apps.evaluation.filters.history import (
AutoevaluationhistoryFilter,
QuickevaluationhistoryFilter,
)
from core.apps.evaluation.models import AutoevaluationhistoryModel, QuickevaluationhistoryModel
from core.apps.evaluation.serializers.history import (
CreateAutoevaluationhistorySerializer,
CreateQuickevaluationhistorySerializer,
ListAutoevaluationhistorySerializer,
ListQuickevaluationhistorySerializer,
RetrieveAutoevaluationhistorySerializer,
RetrieveQuickevaluationhistorySerializer,
)
@extend_schema(
tags=["AutoEvaluationHistory"],
parameters=[
OpenApiParameter("auto_evaluation", int, description="AutoEvaluation ID bo'yicha filter"),
OpenApiParameter("event_type", str, description="Event turi bo'yicha filter"),
OpenApiParameter("created_from", str, description="Boshlanish sanasi (ISO 8601)"),
OpenApiParameter("created_to", str, description="Tugash sanasi (ISO 8601)"),
],
)
class AutoEvaluationHistoryView(BaseViewSetMixin, ReadOnlyModelViewSet):
queryset = AutoevaluationhistoryModel.objects.select_related().all()
serializer_class = ListAutoevaluationhistorySerializer
permission_classes = [AllowAny]
pagination_class = None # History uchun pagination kerak emas
filter_backends = [DjangoFilterBackend, OrderingFilter]
filterset_class = AutoevaluationhistoryFilter
ordering_fields = ["created_at"]
ordering = ["created_at"]
action_permission_classes = {}
action_serializer_class = {
"list": ListAutoevaluationhistorySerializer,
"retrieve": RetrieveAutoevaluationhistorySerializer,
"create": CreateAutoevaluationhistorySerializer,
}
@extend_schema(
tags=["QuickEvaluationHistory"],
parameters=[
OpenApiParameter("quick_evaluation", int, description="QuickEvaluation ID bo'yicha filter"),
OpenApiParameter("event_type", str, description="Event turi bo'yicha filter"),
OpenApiParameter("created_from", str, description="Boshlanish sanasi (ISO 8601)"),
OpenApiParameter("created_to", str, description="Tugash sanasi (ISO 8601)"),
],
)
class QuickEvaluationHistoryView(BaseViewSetMixin, ReadOnlyModelViewSet):
queryset = QuickevaluationhistoryModel.objects.select_related().all()
serializer_class = ListQuickevaluationhistorySerializer
permission_classes = [AllowAny]
pagination_class = None # History uchun pagination kerak emas
filter_backends = [DjangoFilterBackend, OrderingFilter]
filterset_class = QuickevaluationhistoryFilter
ordering_fields = ["created_at"]
ordering = ["created_at"]
action_permission_classes = {}
action_serializer_class = {
"list": ListQuickevaluationhistorySerializer,
"retrieve": RetrieveQuickevaluationhistorySerializer,
"create": CreateQuickevaluationhistorySerializer,
}