mirror of https://github.com/jumpserver/jumpserver
You can not select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
24 lines
820 B
24 lines
820 B
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):
|
|
return str(instance.processor) if instance.processor else ''
|