feat: add mechnic-auto-model
This commit is contained in:
@@ -0,0 +1,39 @@
|
||||
from rest_framework import serializers
|
||||
|
||||
from core.apps.evaluation.models import MechanicAutoevaluationhistoryModel
|
||||
|
||||
|
||||
class BaseMechanicAutoevaluationhistorySerializer(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 = MechanicAutoevaluationhistoryModel
|
||||
fields = [
|
||||
"id",
|
||||
"event_type",
|
||||
"event_type_display",
|
||||
"actor",
|
||||
"meta",
|
||||
"created_at",
|
||||
]
|
||||
|
||||
|
||||
class ListMechanicAutoevaluationhistorySerializer(BaseMechanicAutoevaluationhistorySerializer):
|
||||
class Meta(BaseMechanicAutoevaluationhistorySerializer.Meta): ...
|
||||
|
||||
|
||||
class RetrieveMechanicAutoevaluationhistorySerializer(BaseMechanicAutoevaluationhistorySerializer):
|
||||
class Meta(BaseMechanicAutoevaluationhistorySerializer.Meta):
|
||||
fields = BaseMechanicAutoevaluationhistorySerializer.Meta.fields + ["mechanic_auto_evaluation"]
|
||||
|
||||
|
||||
class CreateMechanicAutoevaluationhistorySerializer(BaseMechanicAutoevaluationhistorySerializer):
|
||||
class Meta(BaseMechanicAutoevaluationhistorySerializer.Meta): ...
|
||||
@@ -1,2 +1,3 @@
|
||||
from .AutoEvaluationHistory import * # noqa
|
||||
from .MechanicAutoEvaluationHistory import * # noqa
|
||||
from .QuickEvaluationHistory import * # noqa
|
||||
|
||||
Reference in New Issue
Block a user