- Create ReferenceitemModel with type, name, parent (self FK), order, is_active fields - Add ReferenceType choices: brand, marka, color, fuel_type, body_type, car_position, state_car - Implement ReferenceItem API (list, retrieve) with filter by type/parent/is_active, search, ordering - Add ReferenceItem admin with list_filter, search, inline editing - Change QuickEvaluation FK fields from shared.OptionsModel to evaluation.ReferenceitemModel - Update serializers and views to use .name instead of .key - Add ReferenceItem to unfold admin navigation
68 lines
1.7 KiB
Python
68 lines
1.7 KiB
Python
from django.contrib import admin
|
|
from unfold.admin import ModelAdmin
|
|
|
|
from core.apps.evaluation.models import QuickEvaluationModel
|
|
|
|
|
|
@admin.register(QuickEvaluationModel)
|
|
class QuickEvaluationAdmin(ModelAdmin):
|
|
list_display = (
|
|
"id",
|
|
"created_by",
|
|
"brand",
|
|
"marka",
|
|
"car_number",
|
|
"car_manufactured_date",
|
|
"estimated_price",
|
|
"status",
|
|
"car_type",
|
|
"state_car",
|
|
"created_at",
|
|
)
|
|
list_filter = (
|
|
"status",
|
|
"car_type",
|
|
)
|
|
search_fields = (
|
|
"car_number",
|
|
"vin_number",
|
|
"engine_number",
|
|
"tex_passport_serie_num",
|
|
)
|
|
readonly_fields = ("created_at", "updated_at")
|
|
autocomplete_fields = ("created_by",)
|
|
fieldsets = (
|
|
("Foydalanuvchi", {
|
|
"fields": ("created_by",),
|
|
}),
|
|
("Tex passport", {
|
|
"fields": (
|
|
"tex_passport_serie_num",
|
|
("tech_passport_issued_date", "tech_passport_issued_place"),
|
|
"tex_passport_file",
|
|
),
|
|
}),
|
|
("Transport ma'lumotlari", {
|
|
"fields": (
|
|
"car_number",
|
|
("brand", "marka"),
|
|
("car_manufactured_date", "color"),
|
|
("vin_number", "engine_number"),
|
|
("distance_covered", "car_position"),
|
|
),
|
|
}),
|
|
("Texnik holat", {
|
|
"fields": (
|
|
("fuel_type", "body_type"),
|
|
("car_type", "state_car"),
|
|
),
|
|
}),
|
|
("Natija", {
|
|
"fields": ("estimated_price", "status"),
|
|
}),
|
|
("Tizim", {
|
|
"classes": ("collapse",),
|
|
"fields": ("created_at", "updated_at"),
|
|
}),
|
|
)
|