perf: 支持持久化设置个人终端主题

pull/11776/head
Eric 1 year ago committed by Bryan
parent 11157563ba
commit d6c0139fef

@ -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):

@ -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):

Loading…
Cancel
Save