From d0f70f4316a6a10704d4e02730a9e6908d4a7d90 Mon Sep 17 00:00:00 2001 From: Bai Date: Mon, 26 Dec 2022 19:16:11 +0800 Subject: [PATCH] =?UTF-8?q?perf:=20=E4=BF=AE=E6=94=B9=E7=94=A8=E6=88=B7?= =?UTF-8?q?=E5=BA=8F=E5=88=97=E7=B1=BB=20can=5Fpublic=5Fkey=5Fauth=20?= =?UTF-8?q?=E7=B1=BB=E5=9E=8B;=20=E4=BF=AE=E6=94=B9=20OPTION=20=E8=8E=B7?= =?UTF-8?q?=E5=8F=96=E5=AD=97=E6=AE=B5=20id=20label=20=E4=B8=BA=20ID?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- apps/common/drf/metadata.py | 4 ++++ apps/users/serializers/user.py | 5 +++-- 2 files changed, 7 insertions(+), 2 deletions(-) diff --git a/apps/common/drf/metadata.py b/apps/common/drf/metadata.py index fc9ceb961..52c89ba43 100644 --- a/apps/common/drf/metadata.py +++ b/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 diff --git a/apps/users/serializers/user.py b/apps/users/serializers/user.py index be083a322..b872f4bd0 100644 --- a/apps/users/serializers/user.py +++ b/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"),