Browse Source

perf: 修改用户序列类 can_public_key_auth 类型; 修改 OPTION 获取字段 id label 为 ID

pull/9244/head
Bai 2 years ago
parent
commit
d0f70f4316
  1. 4
      apps/common/drf/metadata.py
  2. 5
      apps/users/serializers/user.py

4
apps/common/drf/metadata.py

@ -122,6 +122,10 @@ class SimpleMetadataWithFilters(SimpleMetadata):
self.set_tree_field(field, field_info)
elif isinstance(field, serializers.ChoiceField):
self.set_choices_field(field, field_info)
if field.field_name == 'id':
field_info['label'] = 'ID'
return field_info
@staticmethod

5
apps/users/serializers/user.py

@ -83,8 +83,9 @@ class UserSerializer(RolesSerializerMixin, CommonBulkSerializerMixin, serializer
)
login_blocked = serializers.BooleanField(read_only=True, label=_("Login blocked"))
is_expired = serializers.BooleanField(read_only=True, label=_("Is expired"))
can_public_key_auth = serializers.ReadOnlyField(
source="can_use_ssh_key_login", label=_("Can public key authentication")
can_public_key_auth = serializers.BooleanField(
source="can_use_ssh_key_login", label=_("Can public key authentication"),
read_only=True
)
password = EncryptedField(
label=_("Password"),

Loading…
Cancel
Save