Browse Source

perf: Storage update comment failed

pull/13974/head
feng 3 months ago committed by Bryan
parent
commit
ac0c6ef3d5
  1. 16
      apps/terminal/serializers/storage.py

16
apps/terminal/serializers/storage.py

@ -219,7 +219,6 @@ command_storage_type_serializer_classes_mapping = {
class BaseStorageSerializer(serializers.ModelSerializer):
storage_type_serializer_classes_mapping = {}
meta = MethodSerializer()
comment = serializers.SerializerMethodField(label=_('Comment'))
class Meta:
model = None
@ -252,12 +251,15 @@ class BaseStorageSerializer(serializers.ModelSerializer):
serializer = serializer_class
return serializer
@staticmethod
def get_comment(obj):
need_translate_comments = {'Store locally': _('Store locally'), 'Do not save': _('Do not save')}
comment = obj.comment
return need_translate_comments.get(comment, comment)
def to_representation(self, instance):
data = super().to_representation(instance)
need_translate_comments = {
'Store locally': _('Store locally'),
'Do not save': _('Do not save')
}
comment = instance.comment
data['comment'] = need_translate_comments.get(comment, comment)
return data
def save(self, **kwargs):
instance = super().save(**kwargs)

Loading…
Cancel
Save