diff --git a/apps/common/serializers/fields.py b/apps/common/serializers/fields.py index e206afcb3..ef2589628 100644 --- a/apps/common/serializers/fields.py +++ b/apps/common/serializers/fields.py @@ -57,19 +57,10 @@ class EncryptedField(serializers.CharField): class LabeledChoiceField(ChoiceField): - def __init__(self, *args, **kwargs): - super(LabeledChoiceField, self).__init__(*args, **kwargs) - - @property - def choice_mapper(self): - return { - key: value for key, value in self.choices.items() - } - def to_representation(self, key): if key is None: return key - label = self.choice_mapper.get(key, key) + label = self.choices.get(key, key) return {"value": key, "label": label} def to_internal_value(self, data): diff --git a/apps/tickets/serializers/ticket/ticket.py b/apps/tickets/serializers/ticket/ticket.py index c5ed1a8d3..607063367 100644 --- a/apps/tickets/serializers/ticket/ticket.py +++ b/apps/tickets/serializers/ticket/ticket.py @@ -39,10 +39,9 @@ class TicketSerializer(OrgResourceModelSerializerMixin): tp = self.fields.get('type') if not tp: return - excluded_value = TicketType.general - self.fields['type'].choices = [ - (value, label) for value, label in tp.choices.items() if value != excluded_value - ] + choices = tp.choices + choices.pop(TicketType.general, None) + tp.choices = choices.items() @classmethod def setup_eager_loading(cls, queryset):