Settings → Language and time: saving erases a stored language the instance no longer offers #426
Labels
No labels
accessibility
authentication
breaking change
bug
documentation
enhancement
interface
internationalisation
observability
performance
security
tier
1
tier
2
tier
3
tier/4
No project
No assignees
1 participant
Notifications
Due date
No due date set.
Dependencies
No dependencies set
Reference
Postulo/postulo#426
Loading…
Reference in a new issue
No description provided.
Delete branch "%!s()"
Deleting a branch is permanent. Although the deleted branch may continue to exist for a short time before it actually gets removed, it CANNOT be undone in most cases. Continue?
Found on 2026-09-29 in a read-only review of postulo at
95348908d, by saving the Language and time page for somebody whose language had been withdrawn.Checked again on 2026-10-01 against
mainat0a5cad587: still present. The code is now ataccounts/forms.py:178(thesite.offers()test inlanguage_choices()),accounts/forms.py:876-879(theChoiceFieldinLocaleForm.__init__) andaccounts/forms.py:860(language_now());templates/settings/locale.html:59has not moved.#120 settled that withdrawing a language must leave people's stored choice alone, so that offering it again brings them back. The model is left alone, but the settings form is not: it offers a radio only for the languages on offer, so a person whose stored language was withdrawn posts no
languageat all, the optional field cleans to"", and the save writes""over the stored code. Changing only the time zone is enough.accounts/forms.py:177(language_choices()skips a languagesite.offers()refuses, and one whose catalogue nobody has started);accounts/forms.py:879-882(LocaleForm.__init__replaces the field with aChoiceField(..., required=False)built from those choices);templates/settings/locale.html:59(one radio per offered option, so none is checked for the stored code);accounts/forms.py:863language_now().enandpt-pt. A person whose profile holdsdeopens Settings → Language and time, changes the time zone and presses Save. The page had novalue="de"radio, the POST returned 302, andprofile.languagebecame"". Offering German again later does not bring them back. The closed disclosure also shows no current language, becauselanguage_now()finds no selected row and returns an empty one.tests/test_offered_languages.pychecks that narrowing leaves the stored value alone, but only at the model level, never through the form.LocaleForm, keep the stored language when nothing is posted for it: aclean_language()that returnsself.instance.languagewhen"language"is absent fromself.dataand the stored code is not among the choices. Show it in the closed row as the instance default, as #120 asked ("Show them the instance default while the language is not offered"), rather than as a blank.Done when
tests/test_offered_languages.pystoresde, offers onlyenandpt-pt, postssettings:localewith a time zone and no language, and assertsprofile.language == "de"and the new time zone saved; it fails today with"".