Fix validation of strings with leading and trailing newlines (#3003)

We use CharFields for validating original strings and translations when translations are being saved.

By default, CharField strips the value of the leading and trailing whitespace:
https://docs.djangoproject.com/en/4.2/ref/forms/fields/#django.forms.CharField

Until now, we've been only bypassing this default for translations. From now on, we also do that for original strings.
This commit is contained in:
Matjaž Horvat 2023-10-26 10:06:22 +02:00 коммит произвёл GitHub
Родитель 517e9863da
Коммит a2d3d2e28e
Не найден ключ, соответствующий данной подписи
Идентификатор ключа GPG: 4AEE18F83AFDEB23
1 изменённых файлов: 3 добавлений и 0 удалений

Просмотреть файл

@ -51,5 +51,8 @@ class CreateTranslationForm(forms.Form):
return None return None
return self.cleaned_data["plural_form"] return self.cleaned_data["plural_form"]
def clean_original(self):
return self.data.get("original", "")
def clean_translation(self): def clean_translation(self):
return self.data.get("translation", "") return self.data.get("translation", "")