From 96a66e555fbb091d3fe6a922ca56339a39678146 Mon Sep 17 00:00:00 2001 From: ibuler Date: Wed, 14 Jun 2023 14:48:50 +0800 Subject: [PATCH] =?UTF-8?q?perf:=20=E4=BC=98=E5=8C=96=E8=BF=9E=E6=8E=A5?= =?UTF-8?q?=E6=96=B9=E5=BC=8F?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- apps/acls/serializers/command_acl.py | 5 +---- apps/locale/zh/LC_MESSAGES/django.po | 2 +- apps/terminal/connect_methods.py | 14 +++++++++++--- apps/users/serializers/group.py | 4 +--- 4 files changed, 14 insertions(+), 11 deletions(-) diff --git a/apps/acls/serializers/command_acl.py b/apps/acls/serializers/command_acl.py index 16cb615a8..a34ea4cc4 100644 --- a/apps/acls/serializers/command_acl.py +++ b/apps/acls/serializers/command_acl.py @@ -27,13 +27,10 @@ class CommandFilterACLSerializer(BaseSerializer, BulkOrgResourceModelSerializer) command_groups = ObjectRelatedField( queryset=CommandGroup.objects, many=True, required=False, label=_('Command group') ) - command_groups_amount = serializers.IntegerField( - source='command_groups.count', read_only=True, label=_('Command group amount') - ) class Meta(BaseSerializer.Meta): model = CommandFilterACL - fields = BaseSerializer.Meta.fields + ['command_groups', 'command_groups_amount'] + fields = BaseSerializer.Meta.fields + ['command_groups'] class CommandReviewSerializer(serializers.Serializer): diff --git a/apps/locale/zh/LC_MESSAGES/django.po b/apps/locale/zh/LC_MESSAGES/django.po index 7540ebf5d..cb24af05d 100644 --- a/apps/locale/zh/LC_MESSAGES/django.po +++ b/apps/locale/zh/LC_MESSAGES/django.po @@ -686,7 +686,7 @@ msgstr "特殊信息" #: accounts/serializers/account/base.py:81 msgid "Tip: If no username is required for authentication, fill in `null`" -msgstr "提示: 如果认证时不需要用户名,则填写为 null" +msgstr "提示: 如果认证时不需要用户名,可填写为 null" #: accounts/serializers/automations/base.py:23 #: assets/models/asset/common.py:155 assets/models/automations/base.py:18 diff --git a/apps/terminal/connect_methods.py b/apps/terminal/connect_methods.py index 0d1571489..1ed9e14f1 100644 --- a/apps/terminal/connect_methods.py +++ b/apps/terminal/connect_methods.py @@ -69,10 +69,11 @@ class NativeClient(TextChoices): Protocol.rdp: [cls.mstsc], Protocol.mysql: [cls.db_client], Protocol.mariadb: [cls.db_client], - Protocol.oracle: [cls.db_client], - Protocol.postgresql: [cls.db_client], Protocol.redis: [cls.db_client], Protocol.mongodb: [cls.db_client], + + Protocol.oracle: [cls.db_client], + Protocol.postgresql: [cls.db_client], } return clients @@ -90,12 +91,17 @@ class NativeClient(TextChoices): @classmethod def xpack_methods(cls): - return [cls.sqlplus, cls.mstsc] + return [cls.mstsc] + + @classmethod + def xpack_protocols(cls): + return [Protocol.rdp, Protocol.oracle, Protocol.clickhouse, Protocol.sqlserver] @classmethod def get_methods(cls, os='windows'): clients_map = cls.get_native_clients() methods = defaultdict(list) + xpack_protocols = cls.xpack_protocols() for protocol, _clients in clients_map.items(): if isinstance(_clients, dict): @@ -103,6 +109,8 @@ class NativeClient(TextChoices): _clients = list(itertools.chain(*_clients.values())) else: _clients = _clients.get(os, _clients['default']) + if protocol in xpack_protocols: + continue for client in _clients: if not settings.XPACK_ENABLED and client in cls.xpack_methods(): continue diff --git a/apps/users/serializers/group.py b/apps/users/serializers/group.py index 90228d681..dc61eee21 100644 --- a/apps/users/serializers/group.py +++ b/apps/users/serializers/group.py @@ -24,9 +24,7 @@ class UserGroupSerializer(BulkOrgResourceModelSerializer): fields_small = fields_mini + [ 'comment', 'date_created', 'created_by' ] - fields = fields_mini + fields_small + [ - 'users', 'users_amount', - ] + fields = fields_mini + fields_small + ['users'] extra_kwargs = { 'created_by': {'label': _('Created by'), 'read_only': True}, 'users_amount': {'label': _('Users amount')},