Files
jumpserver/apps/tickets/serializers/super_ticket.py
fit2bot 395b868dcf perf: swagger done (#15865)
* perf: swagger upgrade

* perf: upgrade to drf-spectacular

* perf: 添加部分注解

* perf: swagger done

---------

Co-authored-by: ibuler <ibuler@qq.com>
2025-08-27 10:27:01 +08:00

24 lines
827 B
Python

from rest_framework import serializers
from django.utils.translation import gettext_lazy as _
from common.serializers.fields import LabeledChoiceField
from tickets.const import TicketStatus, TicketState
from ..models import SuperTicket
__all__ = ['SuperTicketSerializer']
class SuperTicketSerializer(serializers.ModelSerializer):
status = LabeledChoiceField(choices=TicketStatus.choices, read_only=True, label=_('Status'))
state = LabeledChoiceField(choices=TicketState.choices, read_only=True, label=_("State"))
processor = serializers.SerializerMethodField(label=_("Processor"))
class Meta:
model = SuperTicket
fields = ['id', 'status', 'state', 'processor']
@staticmethod
def get_processor(instance) -> str:
return str(instance.processor) if instance.processor else ''