fix: 修复 connection token 相关的返回字段

pull/9468/head
Bai 2023-02-08 15:16:00 +08:00 committed by Jiangjie.Bai
parent 2c952c2877
commit 37f119260e
1 changed files with 4 additions and 2 deletions

View File

@ -1,8 +1,9 @@
from django.utils.translation import ugettext_lazy as _ from django.utils.translation import ugettext_lazy as _
from rest_framework import serializers from rest_framework import serializers
from common.serializers.fields import EncryptedField from perms.serializers.permission import ActionChoicesField
from orgs.mixins.serializers import OrgResourceModelSerializerMixin from orgs.mixins.serializers import OrgResourceModelSerializerMixin
from common.serializers.fields import EncryptedField
from ..models import ConnectionToken from ..models import ConnectionToken
__all__ = [ __all__ = [
@ -16,6 +17,7 @@ class ConnectionTokenSerializer(OrgResourceModelSerializerMixin):
label=_("Input secret"), max_length=40960, required=False, allow_blank=True label=_("Input secret"), max_length=40960, required=False, allow_blank=True
) )
from_ticket_info = serializers.SerializerMethodField(label=_("Ticket info")) from_ticket_info = serializers.SerializerMethodField(label=_("Ticket info"))
actions = ActionChoicesField()
class Meta: class Meta:
model = ConnectionToken model = ConnectionToken
@ -29,7 +31,7 @@ class ConnectionTokenSerializer(OrgResourceModelSerializerMixin):
] ]
read_only_fields = [ read_only_fields = [
# 普通 Token 不支持指定 user # 普通 Token 不支持指定 user
'user', 'expire_time', 'user', 'expire_time', 'is_expired',
'user_display', 'asset_display', 'user_display', 'asset_display',
] ]
fields = fields_small + read_only_fields fields = fields_small + read_only_fields