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,28 @@
from rest_framework import serializers
from core.apps.evaluation.models import AutoevaluationhistoryModel
class BaseAutoevaluationhistorySerializer(serializers.ModelSerializer):
class Meta:
model = AutoevaluationhistoryModel
fields = [
"id",
"name",
]
class ListAutoevaluationhistorySerializer(BaseAutoevaluationhistorySerializer):
class Meta(BaseAutoevaluationhistorySerializer.Meta): ...
class RetrieveAutoevaluationhistorySerializer(BaseAutoevaluationhistorySerializer):
class Meta(BaseAutoevaluationhistorySerializer.Meta): ...
class CreateAutoevaluationhistorySerializer(BaseAutoevaluationhistorySerializer):
class Meta(BaseAutoevaluationhistorySerializer.Meta):
fields = [
"id",
"name",
]

View File

@@ -0,0 +1,62 @@
from rest_framework import serializers
from core.apps.evaluation.models import AutoevaluationhistoryModel, QuickevaluationhistoryModel
class BaseHistorySerializer(serializers.ModelSerializer):
event_type_display = serializers.CharField(source="get_event_type_display", read_only=True)
actor = serializers.SerializerMethodField()
def get_actor(self, obj):
return {
"id": obj.actor_id,
"full_name": obj.actor_full_name,
"role": obj.actor_role,
}
# ─── AutoEvaluation History ────────────────────────────────────────────────
class ListAutoevaluationhistorySerializer(BaseHistorySerializer):
class Meta:
model = AutoevaluationhistoryModel
fields = [
"id",
"event_type",
"event_type_display",
"actor",
"meta",
"created_at",
]
class RetrieveAutoevaluationhistorySerializer(ListAutoevaluationhistorySerializer):
class Meta(ListAutoevaluationhistorySerializer.Meta):
fields = ListAutoevaluationhistorySerializer.Meta.fields + ["auto_evaluation"]
# Read-only — API orqali yozilmaydi, faqat signallar yozadi
CreateAutoevaluationhistorySerializer = ListAutoevaluationhistorySerializer
# ─── QuickEvaluation History ───────────────────────────────────────────────
class ListQuickevaluationhistorySerializer(BaseHistorySerializer):
class Meta:
model = QuickevaluationhistoryModel
fields = [
"id",
"event_type",
"event_type_display",
"actor",
"meta",
"created_at",
]
class RetrieveQuickevaluationhistorySerializer(ListQuickevaluationhistorySerializer):
class Meta(ListQuickevaluationhistorySerializer.Meta):
fields = ListQuickevaluationhistorySerializer.Meta.fields + ["quick_evaluation"]
CreateQuickevaluationhistorySerializer = ListQuickevaluationhistorySerializer

View File

@@ -0,0 +1,28 @@
from rest_framework import serializers
from core.apps.evaluation.models import QuickevaluationhistoryModel
class BaseQuickevaluationhistorySerializer(serializers.ModelSerializer):
class Meta:
model = QuickevaluationhistoryModel
fields = [
"id",
"name",
]
class ListQuickevaluationhistorySerializer(BaseQuickevaluationhistorySerializer):
class Meta(BaseQuickevaluationhistorySerializer.Meta): ...
class RetrieveQuickevaluationhistorySerializer(BaseQuickevaluationhistorySerializer):
class Meta(BaseQuickevaluationhistorySerializer.Meta): ...
class CreateQuickevaluationhistorySerializer(BaseQuickevaluationhistorySerializer):
class Meta(BaseQuickevaluationhistorySerializer.Meta):
fields = [
"id",
"name",
]

View File

@@ -0,0 +1,8 @@
from .History import ( # noqa
CreateAutoevaluationhistorySerializer,
CreateQuickevaluationhistorySerializer,
ListAutoevaluationhistorySerializer,
ListQuickevaluationhistorySerializer,
RetrieveAutoevaluationhistorySerializer,
RetrieveQuickevaluationhistorySerializer,
)