worked_hours to'g'irlandi

This commit is contained in:
2026-04-02 17:17:49 +05:00
parent 9d8fd8e6de
commit e9d779d489
5 changed files with 64 additions and 94 deletions

View File

@@ -4,11 +4,25 @@ from core.apps.evaluation.models import AutoevaluationhistoryModel
class BaseAutoevaluationhistorySerializer(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,
}
class Meta:
model = AutoevaluationhistoryModel
fields = [
"id",
"name",
"event_type",
"event_type_display",
"actor",
"meta",
"created_at",
]
@@ -17,12 +31,9 @@ class ListAutoevaluationhistorySerializer(BaseAutoevaluationhistorySerializer):
class RetrieveAutoevaluationhistorySerializer(BaseAutoevaluationhistorySerializer):
class Meta(BaseAutoevaluationhistorySerializer.Meta): ...
class Meta(BaseAutoevaluationhistorySerializer.Meta):
fields = BaseAutoevaluationhistorySerializer.Meta.fields + ["auto_evaluation"]
class CreateAutoevaluationhistorySerializer(BaseAutoevaluationhistorySerializer):
class Meta(BaseAutoevaluationhistorySerializer.Meta):
fields = [
"id",
"name",
]
class Meta(BaseAutoevaluationhistorySerializer.Meta): ...

View File

@@ -1,62 +0,0 @@
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

@@ -4,11 +4,25 @@ from core.apps.evaluation.models import QuickevaluationhistoryModel
class BaseQuickevaluationhistorySerializer(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,
}
class Meta:
model = QuickevaluationhistoryModel
fields = [
"id",
"name",
"event_type",
"event_type_display",
"actor",
"meta",
"created_at",
]
@@ -17,12 +31,9 @@ class ListQuickevaluationhistorySerializer(BaseQuickevaluationhistorySerializer)
class RetrieveQuickevaluationhistorySerializer(BaseQuickevaluationhistorySerializer):
class Meta(BaseQuickevaluationhistorySerializer.Meta): ...
class Meta(BaseQuickevaluationhistorySerializer.Meta):
fields = BaseQuickevaluationhistorySerializer.Meta.fields + ["quick_evaluation"]
class CreateQuickevaluationhistorySerializer(BaseQuickevaluationhistorySerializer):
class Meta(BaseQuickevaluationhistorySerializer.Meta):
fields = [
"id",
"name",
]
class Meta(BaseQuickevaluationhistorySerializer.Meta): ...

View File

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