feat: avto va tezkor baholash uchun history bo'limi qo'shildi
This commit is contained in:
@@ -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
|
||||
|
||||
@@ -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",
|
||||
]
|
||||
62
core/apps/evaluation/serializers/history/History.py
Normal file
62
core/apps/evaluation/serializers/history/History.py
Normal 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
|
||||
@@ -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",
|
||||
]
|
||||
8
core/apps/evaluation/serializers/history/__init__.py
Normal file
8
core/apps/evaluation/serializers/history/__init__.py
Normal file
@@ -0,0 +1,8 @@
|
||||
from .History import ( # noqa
|
||||
CreateAutoevaluationhistorySerializer,
|
||||
CreateQuickevaluationhistorySerializer,
|
||||
ListAutoevaluationhistorySerializer,
|
||||
ListQuickevaluationhistorySerializer,
|
||||
RetrieveAutoevaluationhistorySerializer,
|
||||
RetrieveQuickevaluationhistorySerializer,
|
||||
)
|
||||
Reference in New Issue
Block a user