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):
|
||||
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…
Reference in New Issue