From a8b22d726e087b68029f8972a28db6872b94bc35 Mon Sep 17 00:00:00 2001 From: Szabo Zoltan Date: Mon, 22 Jul 2024 18:28:26 +0200 Subject: [PATCH] Add appealtype name to ops-learning --- per/serializers.py | 17 ++++++++++++++++- 1 file changed, 16 insertions(+), 1 deletion(-) diff --git a/per/serializers.py b/per/serializers.py index 731a161c8..5ba78e057 100644 --- a/per/serializers.py +++ b/per/serializers.py @@ -6,7 +6,7 @@ from drf_spectacular.utils import extend_schema_field from rest_framework import serializers -from api.models import Appeal, Country, Region +from api.models import Appeal, AppealType, Country, Region from api.serializers import ( MiniCountrySerializer, RegoCountrySerializer, @@ -867,6 +867,7 @@ class Meta: class MiniAppealSerializer(serializers.ModelSerializer): name = serializers.SerializerMethodField() start_date = serializers.SerializerMethodField() + atype = serializers.SerializerMethodField() dtype = serializers.SerializerMethodField() country = serializers.SerializerMethodField() region = serializers.SerializerMethodField() @@ -881,6 +882,10 @@ def get_name(obj): def get_start_date(obj): return obj.start_date and obj.start_date.year + @staticmethod + def get_atype(obj): + return obj.atype or AppealType(obj.atype).label + @staticmethod def get_dtype(obj): return obj.dtype and obj.dtype.name @@ -918,6 +923,11 @@ class Meta: class FullAppealSerializer(serializers.ModelSerializer): + atype = serializers.SerializerMethodField() + + @staticmethod + def get_atype(obj): + return obj.atype or AppealType(obj.atype).label class Meta: model = Appeal @@ -925,6 +935,11 @@ class Meta: class MicroAppealSerializer(serializers.ModelSerializer): + atype = serializers.SerializerMethodField() + + @staticmethod + def get_atype(obj): + return obj.atype or AppealType(obj.atype).label class Meta: model = Appeal