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:
Husanjonazamov
2026-03-10 12:10:28 +05:00
parent b3581233c1
commit 5c2fe032d0
13 changed files with 1021 additions and 78 deletions

View File

@@ -3,8 +3,7 @@ from django.utils.translation import gettext_lazy as _
from django_core.models import AbstractBaseModel
from model_bakery import baker
from core.apps.evaluation.choices.vehicle import FuelType, BodyType, VehicleCondition
from core.apps.evaluation.choices.vehicle import VehicleCondition
class VehicleModel(AbstractBaseModel):
@@ -25,11 +24,21 @@ class VehicleModel(AbstractBaseModel):
license_plate = models.CharField(
verbose_name=_("license plate"), max_length=20, blank=True, null=True
)
brand = models.CharField(
verbose_name=_("brand"), max_length=100, blank=True, null=True
brand = models.ForeignKey(
"evaluation.ReferenceitemModel",
on_delete=models.SET_NULL,
null=True,
blank=True,
related_name="vehicle_brands",
verbose_name=_("brand"),
)
model = models.CharField(
verbose_name=_("model"), max_length=100, blank=True, null=True
model = models.ForeignKey(
"evaluation.ReferenceitemModel",
on_delete=models.SET_NULL,
null=True,
blank=True,
related_name="vehicle_models",
verbose_name=_("model"),
)
manufacture_year = models.IntegerField(
verbose_name=_("manufacture year"), blank=True, null=True
@@ -40,27 +49,34 @@ class VehicleModel(AbstractBaseModel):
engine_number = models.CharField(
verbose_name=_("engine number"), max_length=50, blank=True, null=True
)
color = models.CharField(
verbose_name=_("color"), max_length=50, blank=True, null=True
color = models.ForeignKey(
"evaluation.ReferenceitemModel",
on_delete=models.SET_NULL,
null=True,
blank=True,
related_name="vehicle_colors",
verbose_name=_("color"),
)
# 🛠 Texnik holati
mileage = models.IntegerField(
verbose_name=_("mileage"), blank=True, null=True, help_text=_("Distance in km")
)
fuel_type = models.CharField(
fuel_type = models.ForeignKey(
"evaluation.ReferenceitemModel",
on_delete=models.SET_NULL,
null=True,
blank=True,
related_name="vehicle_fuel_types",
verbose_name=_("fuel type"),
max_length=20,
choices=FuelType.choices,
blank=True,
null=True,
)
body_type = models.CharField(
verbose_name=_("body type"),
max_length=20,
choices=BodyType.choices,
blank=True,
body_type = models.ForeignKey(
"evaluation.ReferenceitemModel",
on_delete=models.SET_NULL,
null=True,
blank=True,
related_name="vehicle_body_types",
verbose_name=_("body type"),
)
condition = models.CharField(
verbose_name=_("condition"),
@@ -69,12 +85,19 @@ class VehicleModel(AbstractBaseModel):
blank=True,
null=True,
)
position = models.CharField(
verbose_name=_("position"), max_length=50, blank=True, null=True
position = models.ForeignKey(
"evaluation.ReferenceitemModel",
on_delete=models.SET_NULL,
null=True,
blank=True,
related_name="vehicle_positions",
verbose_name=_("position"),
)
def __str__(self):
return f"{self.brand} {self.model} ({self.license_plate})"
brand_name = self.brand.name if self.brand else ""
model_name = self.model.name if self.model else ""
return f"{brand_name} {model_name} ({self.license_plate})"
@classmethod
def _baker(cls):