From d6c0139fef8b1b391808cb7259ae7ee96d843a3e Mon Sep 17 00:00:00 2001 From: Eric Date: Mon, 9 Oct 2023 15:40:54 +0800 Subject: [PATCH] =?UTF-8?q?perf:=20=E6=94=AF=E6=8C=81=E6=8C=81=E4=B9=85?= =?UTF-8?q?=E5=8C=96=E8=AE=BE=E7=BD=AE=E4=B8=AA=E4=BA=BA=E7=BB=88=E7=AB=AF?= =?UTF-8?q?=E4=B8=BB=E9=A2=98?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- apps/authentication/api/connection_token.py | 17 +++++++++++------ apps/users/serializers/preference/koko.py | 2 ++ 2 files changed, 13 insertions(+), 6 deletions(-) diff --git a/apps/authentication/api/connection_token.py b/apps/authentication/api/connection_token.py index 8d7c753a9..b0756d4aa 100644 --- a/apps/authentication/api/connection_token.py +++ b/apps/authentication/api/connection_token.py @@ -314,13 +314,18 @@ class ConnectionTokenViewSet(ExtraActionApiMixin, RootOrgViewMixin, JMSModelView return super().perform_create(serializer) def _insert_connect_options(self, data, user): - name = 'file_name_conflict_resolution' connect_options = data.pop('connect_options', {}) - preference = Preference.objects.filter( - name=name, user=user, category='koko' - ).first() - value = preference.value if preference else FileNameConflictResolution.REPLACE - connect_options[name] = value + default_name_opts = { + 'file_name_conflict_resolution': FileNameConflictResolution.REPLACE, + 'terminal_theme_name': 'Default', + } + preferences_query = Preference.objects.filter( + user=user, category='koko', name__in=default_name_opts.keys() + ).values_list('name', 'value') + preferences = dict(preferences_query) + for name in default_name_opts.keys(): + value = preferences.get(name, default_name_opts[name]) + connect_options[name] = value data['connect_options'] = connect_options def validate_serializer(self, serializer): diff --git a/apps/users/serializers/preference/koko.py b/apps/users/serializers/preference/koko.py index 5c7ac2e8d..9a37c13a6 100644 --- a/apps/users/serializers/preference/koko.py +++ b/apps/users/serializers/preference/koko.py @@ -9,6 +9,8 @@ class BasicSerializer(serializers.Serializer): FileNameConflictResolution.choices, default=FileNameConflictResolution.REPLACE, required=False, label=_('File name conflict resolution') ) + terminal_theme_name = serializers.CharField( + max_length=128, required=False, default='Default', label=_('Terminal theme name')) class KokoSerializer(serializers.Serializer):