Commit d814a214 authored by Aurélien Bompard's avatar Aurélien Bompard

Use a custom widget for RadioSelect to enable change detection

parent ddd22835
......@@ -57,6 +57,21 @@ class ListOfStringsField(forms.Field):
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 @@ class UserPreferences(forms.Form):
'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 @@ class UserPreferences(forms.Form):
'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 @@ class UserPreferences(forms.Form):
'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=_(
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment