Optionally ask for email addresses twice

This commit is contained in:
Raphael Michel
2017-06-26 17:06:20 +02:00
parent e0fe78b82e
commit 433512a256
4 changed files with 21 additions and 0 deletions

View File

@@ -35,6 +35,10 @@ DEFAULTS = {
'default': 'False',
'type': bool
},
'order_email_asked_twice': {
'default': 'False',
'type': bool
},
'invoice_address_asked': {
'default': 'True',
'type': bool,

View File

@@ -275,6 +275,11 @@ class EventSettingsForm(SettingsForm):
required=False,
widget=forms.CheckboxInput(attrs={'data-checkbox-dependency': '#id_settings-attendee_emails_asked'}),
)
order_email_asked_twice = forms.BooleanField(
label=_("Ask for the order email address twice"),
help_text=_("Require customers to fill in the primary email address twice to avoid errors."),
required=False,
)
max_items_per_order = forms.IntegerField(
min_value=1,
label=_("Maximum number of items per order"),

View File

@@ -42,6 +42,7 @@
{% bootstrap_field sform.max_items_per_order layout="horizontal" %}
{% bootstrap_field sform.attendee_names_asked layout="horizontal" %}
{% bootstrap_field sform.attendee_names_required layout="horizontal" %}
{% bootstrap_field sform.order_email_asked_twice layout="horizontal" %}
{% bootstrap_field sform.attendee_emails_asked layout="horizontal" %}
{% bootstrap_field sform.attendee_emails_required layout="horizontal" %}
{% bootstrap_field sform.cancel_allow_user layout="horizontal" %}

View File

@@ -26,12 +26,23 @@ class ContactForm(forms.Form):
self.event = kwargs.pop('event')
super().__init__(*args, **kwargs)
if self.event.settings.order_email_asked_twice:
self.fields['email_repeat'] = forms.EmailField(
label=_('E-mail address (repeated)'),
help_text=_('Please enter the same email address again to make sure you typed it correctly.')
)
responses = contact_form_fields.send(self.event)
for r, response in sorted(responses, key=lambda r: str(r[0])):
for key, value in response.items():
# We need to be this explicit, since OrderedDict.update does not retain ordering
self.fields[key] = value
def clean(self):
if self.event.settings.order_email_asked_twice:
if self.cleaned_data['email'] != self.cleaned_data['email_repeat']:
raise ValidationError(_('Please enter the same email address twice.'))
class InvoiceAddressForm(forms.ModelForm):