diff --git a/apps/terminal/serializers/storage.py b/apps/terminal/serializers/storage.py index 041d51d22..c90c77866 100644 --- a/apps/terminal/serializers/storage.py +++ b/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)