locale: Split the language selection form into a mixin

- It may not be a good thing for the user created/edit forms to inherit from
  Django Form and ModelForm at the same time. So, simply by introducing a
  minimal mixin.

- Save only when committing.

- Use auto-saving feature.

Signed-off-by: Sunil Mohan Adapa <sunil@medhas.org>
Reviewed-by: James Valleroy <jvalleroy@mailbox.org>
This commit is contained in:
Sunil Mohan Adapa authored and James Valleroy committed 2018-02-21 21:08:33 +01:00
1 parent 842000a01f
commit 6090d5c37d
3 files changed
+27 -13

No files matched your search

+8 -2
View File
@@ -52,8 +52,8 @@ class DomainSelectionForm(forms.Form):
'changed later.'), choices=[])
class LanguageSelectionForm(forms.Form):
"""Form for selecting the user's preferred language """
class LanguageSelectionFormMixin:
"""Form mixin for selecting the user's preferred language."""
language = forms.ChoiceField(
label=_('Language'),
@@ -76,3 +76,9 @@ class LanguageSelectionForm(forms.Form):
get_language_info(language_code)['name_local']))
self.fields['language'].choices = supported_languages
class LanguageSelectionForm(LanguageSelectionFormMixin, forms.Form):
"""Language selection form."""
language = LanguageSelectionFormMixin.language