perf: 获取用户授权的账号返回 has_username 字段

pull/9122/head
Bai 2022-11-24 17:04:27 +08:00
parent 4574161009
commit 99f5c02d84
2 changed files with 6 additions and 6 deletions

View File

@ -62,6 +62,10 @@ class BaseAccount(JMSOrgBaseModel):
def has_secret(self):
return bool(self.secret)
@property
def has_username(self):
return bool(self.username)
@property
def specific(self):
data = {}

View File

@ -12,7 +12,7 @@ from perms.serializers.permission import ActionChoicesField
__all__ = [
'NodeGrantedSerializer', 'AssetGrantedSerializer',
'ActionsSerializer', 'AccountsPermedSerializer'
'AccountsPermedSerializer'
]
@ -43,14 +43,10 @@ class NodeGrantedSerializer(serializers.ModelSerializer):
read_only_fields = fields
class ActionsSerializer(serializers.Serializer):
actions = ActionChoicesField(read_only=True)
class AccountsPermedSerializer(serializers.ModelSerializer):
actions = ActionChoicesField(read_only=True)
class Meta:
model = Account
fields = ['id', 'name', 'username', 'secret_type', 'has_secret', 'actions']
fields = ['id', 'name', 'has_username', 'username', 'has_secret', 'secret_type', 'actions']
read_only_fields = fields