|
|
|
@ -46,7 +46,7 @@ class _SimpleAccountSerializer(serializers.ModelSerializer):
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
class _ConnectionTokenAccountSerializer(serializers.ModelSerializer): |
|
|
|
|
su_from = _SimpleAccountSerializer(required=False, label=_('Su from')) |
|
|
|
|
su_from = serializers.SerializerMethodField(label=_('Su from')) |
|
|
|
|
secret_type = LabeledChoiceField(choices=SecretType.choices, required=False, label=_('Secret type')) |
|
|
|
|
|
|
|
|
|
class Meta: |
|
|
|
@ -56,6 +56,14 @@ class _ConnectionTokenAccountSerializer(serializers.ModelSerializer):
|
|
|
|
|
'secret', 'su_from', 'privileged' |
|
|
|
|
] |
|
|
|
|
|
|
|
|
|
@staticmethod |
|
|
|
|
def get_su_from(account): |
|
|
|
|
su_enabled = account.asset.platform.su_enabled |
|
|
|
|
su_from = account.su_from |
|
|
|
|
if not su_from or not su_enabled: |
|
|
|
|
return |
|
|
|
|
return _SimpleAccountSerializer(su_from).data |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
class _ConnectionTokenGatewaySerializer(serializers.ModelSerializer): |
|
|
|
|
account = _SimpleAccountSerializer( |
|
|
|
|