mirror of
https://github.com/jumpserver/jumpserver.git
synced 2025-09-22 20:09:54 +00:00
* perf: swagger upgrade * perf: upgrade to drf-spectacular * perf: 添加部分注解 * perf: swagger done --------- Co-authored-by: ibuler <ibuler@qq.com>
24 lines
827 B
Python
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 ''
|