symposion_app/pinaxcon/registrasion/forms.py
James Polley 3f4050d96f Use a YesNo field for T&C/CoC agreement
Using a checkbox doesn't make it obvious that this is required.
2017-10-01 14:48:59 +11:00

32 lines
845 B
Python

from pinaxcon.registrasion import models
from django import forms
class YesNoField(forms.TypedChoiceField):
def __init__(self, *args, **kwargs):
kwargs['required'] = True
super(YesNoField, self).__init__(
*args,
coerce=lambda x: x in ['True', 'Yes', True],
choices=((None, '--------'), (False, 'No'), (True, 'Yes')),
**kwargs
)
class ProfileForm(forms.ModelForm):
''' A form for requesting badge and profile information. '''
required_css_class = 'label-required'
class Meta:
model = models.AttendeeProfile
exclude = ['attendee']
widgets = {
'past_lca': forms.widgets.CheckboxSelectMultiple
}
field_classes = {
"of_legal_age": YesNoField,
"agreement": YesNoField,
}