mirror of https://github.com/jumpserver/jumpserver
perf: Storage update comment failed
parent
e13741827d
commit
ac0c6ef3d5
|
@ -219,7 +219,6 @@ command_storage_type_serializer_classes_mapping = {
|
||||||
class BaseStorageSerializer(serializers.ModelSerializer):
|
class BaseStorageSerializer(serializers.ModelSerializer):
|
||||||
storage_type_serializer_classes_mapping = {}
|
storage_type_serializer_classes_mapping = {}
|
||||||
meta = MethodSerializer()
|
meta = MethodSerializer()
|
||||||
comment = serializers.SerializerMethodField(label=_('Comment'))
|
|
||||||
|
|
||||||
class Meta:
|
class Meta:
|
||||||
model = None
|
model = None
|
||||||
|
@ -252,12 +251,15 @@ class BaseStorageSerializer(serializers.ModelSerializer):
|
||||||
serializer = serializer_class
|
serializer = serializer_class
|
||||||
return serializer
|
return serializer
|
||||||
|
|
||||||
@staticmethod
|
def to_representation(self, instance):
|
||||||
def get_comment(obj):
|
data = super().to_representation(instance)
|
||||||
|
need_translate_comments = {
|
||||||
need_translate_comments = {'Store locally': _('Store locally'), 'Do not save': _('Do not save')}
|
'Store locally': _('Store locally'),
|
||||||
comment = obj.comment
|
'Do not save': _('Do not save')
|
||||||
return need_translate_comments.get(comment, comment)
|
}
|
||||||
|
comment = instance.comment
|
||||||
|
data['comment'] = need_translate_comments.get(comment, comment)
|
||||||
|
return data
|
||||||
|
|
||||||
def save(self, **kwargs):
|
def save(self, **kwargs):
|
||||||
instance = super().save(**kwargs)
|
instance = super().save(**kwargs)
|
||||||
|
|
Loading…
Reference in New Issue