feat(auto-evaluation): to'liq CRUD API va 4 bosqichli forma qo'shildi
- 10 ta yangi choice klass qo'shildi: ObjectOwnerType, PropertyRights, FormOwnership, LocationHighways, LocationConvenience, AutoCarType, AutoCarWheel - AutoEvaluationModel ga ~30 ta yangi field qo'shildi (4 bosqich): 1-bosqich: ro'yxatga olish raqami, sanalar, ob'ekt turi 2-bosqich: egasi ma'lumotlari (jismoniy/yuridik), mulk huquqi, egalik shakli 3-bosqich: manzil (viloyat, tuman, shahar, mahalla, ko'cha, uy) 4-bosqich: avtomobil (tex passport, marka, model, raqam, rang, dvigatel) - CreateSerializer ga validatsiya qo'shildi: passport formati (AA 1234567), tex passport formati (AAA 1234567), egasi turiga qarab majburiy fieldlar (jismoniy yoki yuridik) - View ReadOnlyModelViewSet dan ModelViewSet ga o'zgartirildi - Admin 4 bosqichli fieldset bilan yangilandi - Yangi filterlar: object_owner_type, property_rights, form_ownership - VehicleModel fieldlari FK → ReferenceitemModel ga o'tkazildi - Migratsiyalar: 0015, 0016, 0017
This commit is contained in:
@@ -1,8 +1,11 @@
|
||||
from django_core.mixins import BaseViewSetMixin
|
||||
from django_filters.rest_framework import DjangoFilterBackend
|
||||
from drf_spectacular.utils import extend_schema
|
||||
from rest_framework.filters import OrderingFilter, SearchFilter
|
||||
from rest_framework.permissions import AllowAny
|
||||
from rest_framework.viewsets import ReadOnlyModelViewSet
|
||||
from rest_framework.viewsets import ModelViewSet
|
||||
|
||||
from core.apps.evaluation.filters.auto import AutoevaluationFilter
|
||||
from core.apps.evaluation.models import AutoEvaluationModel
|
||||
from core.apps.evaluation.serializers.auto import (
|
||||
CreateAutoevaluationSerializer,
|
||||
@@ -12,11 +15,52 @@ from core.apps.evaluation.serializers.auto import (
|
||||
|
||||
|
||||
@extend_schema(tags=["AutoEvaluation"])
|
||||
class AutoEvaluationView(BaseViewSetMixin, ReadOnlyModelViewSet):
|
||||
queryset = AutoEvaluationModel.objects.all()
|
||||
class AutoEvaluationView(BaseViewSetMixin, ModelViewSet):
|
||||
queryset = AutoEvaluationModel.objects.select_related(
|
||||
"valuation",
|
||||
"valuation__customer",
|
||||
"vehicle",
|
||||
).all()
|
||||
serializer_class = ListAutoevaluationSerializer
|
||||
permission_classes = [AllowAny]
|
||||
|
||||
filter_backends = [DjangoFilterBackend, SearchFilter, OrderingFilter]
|
||||
filterset_class = AutoevaluationFilter
|
||||
search_fields = [
|
||||
"registration_number",
|
||||
"car_model",
|
||||
"car_brand",
|
||||
"car_number",
|
||||
]
|
||||
ordering_fields = [
|
||||
"registration_number",
|
||||
"contract_date",
|
||||
"object_inspection_date",
|
||||
"rate_date",
|
||||
"rate_report_date",
|
||||
"rate_object_name",
|
||||
"object_type",
|
||||
"object_owner_type",
|
||||
"object_location_province",
|
||||
"object_location_district",
|
||||
"object_location_city",
|
||||
"tex_passport_serie_num",
|
||||
"tex_passport_gived_date",
|
||||
"car_brand",
|
||||
"car_model",
|
||||
"car_number",
|
||||
"manufacture_year",
|
||||
"car_color",
|
||||
"property_rights",
|
||||
"form_ownership",
|
||||
"value_determined",
|
||||
"rate_type",
|
||||
"status",
|
||||
"created_at",
|
||||
"updated_at",
|
||||
]
|
||||
ordering = ["-created_at"]
|
||||
|
||||
action_permission_classes = {}
|
||||
action_serializer_class = {
|
||||
"list": ListAutoevaluationSerializer,
|
||||
|
||||
@@ -13,7 +13,9 @@ from core.apps.evaluation.serializers.vehicle import (
|
||||
|
||||
@extend_schema(tags=["Vehicle"])
|
||||
class VehicleView(BaseViewSetMixin, ReadOnlyModelViewSet):
|
||||
queryset = VehicleModel.objects.all()
|
||||
queryset = VehicleModel.objects.select_related(
|
||||
"brand", "model", "color", "fuel_type", "body_type", "position",
|
||||
).all()
|
||||
serializer_class = ListVehicleSerializer
|
||||
permission_classes = [AllowAny]
|
||||
|
||||
|
||||
Reference in New Issue
Block a user