diff --git a/src/postorius/forms.py b/src/postorius/forms.py index 6fd6872..a264266 100644 --- a/src/postorius/forms.py +++ b/src/postorius/forms.py @@ -57,6 +57,21 @@ return result +class NullBooleanRadioSelect(forms.RadioSelect): + """ + This is necessary to detect that such a field has not been changed. + """ + + def value_from_datadict(self, data, files, name): + value = data.get(name, None) + return {'2': True, + True: True, + 'True': True, + '3': False, + 'False': False, + False: False}.get(value, None) + + class SiteModelChoiceField(forms.ModelChoiceField): def label_from_instance(self, obj): @@ -774,7 +789,7 @@ 'preferred, but if you have a problem reading them, select ' 'plain text digests.')) receive_own_postings = forms.NullBooleanField( - widget=forms.RadioSelect(choices=choices), + widget=NullBooleanRadioSelect(choices=choices), required=False, label=_('Receive own postings'), help_text=_( @@ -783,13 +798,13 @@ 'to No.' )) acknowledge_posts = forms.NullBooleanField( - widget=forms.RadioSelect(choices=choices), + widget=NullBooleanRadioSelect(choices=choices), required=False, label=_('Acknowledge posts'), help_text=_( 'Receive acknowledgement mail when you send mail to the list?')) hide_address = forms.NullBooleanField( - widget=forms.RadioSelect(choices=choices), + widget=NullBooleanRadioSelect(choices=choices), required=False, label=_('Hide address'), help_text=_( @@ -799,7 +814,7 @@ 'If you do not want your email address to show up on this ' 'membership roster at all, select Yes for this option.')) receive_list_copy = forms.NullBooleanField( - widget=forms.RadioSelect(choices=choices), + widget=NullBooleanRadioSelect(choices=choices), required=False, label=_('Avoid Duplicates'), help_text=_(