diff --git a/src/pretix/base/forms/__init__.py b/src/pretix/base/forms/__init__.py index d97d807e29..1723060f91 100644 --- a/src/pretix/base/forms/__init__.py +++ b/src/pretix/base/forms/__init__.py @@ -118,6 +118,27 @@ class SettingsForm(i18nfield.forms.I18nFormMixin, HierarkeyForm): self.cleaned_data[k] = self.initial[k] return super().save() + def clean(self): + d = super().clean() + + # There is logic in HierarkeyForm.save() to only persist fields that changed. HierarkeyForm determines if + # something changed by comparing `self._s.get(name)` to `value`. This leaves an edge case open for multi-lingual + # text fields. On the very first load, the initial value in `self._s.get(name)` will be a LazyGettextProxy-based + # string. However, only some of the languages are usually visible, so even if the user does not change anything + # at all, it will be considered a changed value and stored. We do not want that, as it makes it very hard to add + # languages to an organizer/event later on. So we trick it and make sure nothing gets changed in that situation. + for name, field in self.fields.items(): + if isinstance(field, i18nfield.forms.I18nFormField): + value = d.get(name) + if not value: + continue + + current = self._s.get(name, as_type=type(value)) + if name not in self.changed_data: + d[name] = current + + return d + def get_new_filename(self, name: str) -> str: from pretix.base.models import Event diff --git a/src/setup.py b/src/setup.py index edc8fd1aec..5af825d01b 100644 --- a/src/setup.py +++ b/src/setup.py @@ -178,7 +178,7 @@ setup( 'django-formtools==2.3', 'django-hierarkey==1.0.*,>=1.0.4', 'django-hijack>=2.2.0,<2.3.0', - 'django-i18nfield==1.9.*,>=1.9.3', + 'django-i18nfield==1.9.*,>=1.9.4', 'django-libsass==0.9', 'django-localflavor==3.1', 'django-markup',