mirror of
https://github.com/pretix/pretix.git
synced 2026-05-10 16:04:02 +00:00
Add attendee email field (#466)
* Add attendee email field * exports, tests
This commit is contained in:
@@ -202,6 +202,11 @@ class QuestionsStep(QuestionsViewMixin, CartMixin, TemplateFlowStep):
|
||||
if warn:
|
||||
messages.warning(request, _('Please fill in answers to all required questions.'))
|
||||
return False
|
||||
if cp.item.admission and self.request.event.settings.get('attendee_emails_required', as_type=bool) \
|
||||
and cp.attendee_email is None:
|
||||
if warn:
|
||||
messages.warning(request, _('Please fill in answers to all required questions.'))
|
||||
return False
|
||||
return True
|
||||
|
||||
def get_context_data(self, **kwargs):
|
||||
|
||||
@@ -9,7 +9,10 @@ from pretix.base.models.orders import InvoiceAddress
|
||||
|
||||
|
||||
class ContactForm(forms.Form):
|
||||
email = forms.EmailField(label=_('E-mail'))
|
||||
email = forms.EmailField(label=_('E-mail'),
|
||||
help_text=_('Make sure to enter a valid email address. We will send you an order '
|
||||
'confirmation including a link that you need in case you want to make '
|
||||
'modifications to your order or download your ticket later.'))
|
||||
|
||||
|
||||
class InvoiceAddressForm(forms.ModelForm):
|
||||
@@ -67,6 +70,12 @@ class QuestionsForm(forms.Form):
|
||||
label=_('Attendee name'),
|
||||
initial=(cartpos.attendee_name if cartpos else orderpos.attendee_name)
|
||||
)
|
||||
if item.admission and event.settings.attendee_emails_asked:
|
||||
self.fields['attendee_email'] = forms.EmailField(
|
||||
required=event.settings.attendee_emails_required,
|
||||
label=_('Attendee email'),
|
||||
initial=(cartpos.attendee_email if cartpos else orderpos.attendee_email)
|
||||
)
|
||||
|
||||
for q in questions:
|
||||
# Do we already have an answer? Provide it as the initial value
|
||||
|
||||
@@ -18,6 +18,10 @@
|
||||
<dt>{% trans "Attendee name" %}</dt>
|
||||
<dd>{% if line.attendee_name %}{{ line.attendee_name }}{% else %}<em>{% trans "not answered" %}</em>{% endif %}</dd>
|
||||
{% endif %}
|
||||
{% if line.item.admission and event.settings.attendee_emails_asked%}
|
||||
<dt>{% trans "Attendee email" %}</dt>
|
||||
<dd>{% if line.attendee_email %}{{ line.attendee_email }}{% else %}<em>{% trans "not answered" %}</em>{% endif %}</dd>
|
||||
{% endif %}
|
||||
{% for q in line.questions %}
|
||||
<dt>{{ q.question }}</dt>
|
||||
<dd>{% if q.answer %}{{ q.answer|linebreaksbr }}{% else %}<em>{% trans "not answered" %}</em>{% endif %}</dd>
|
||||
|
||||
@@ -46,8 +46,13 @@ class CartMixin:
|
||||
i = pos.pk
|
||||
if downloads:
|
||||
return i, pos.pk, 0, 0, 0, 0,
|
||||
if answers and ((pos.item.admission and self.request.event.settings.attendee_names_asked)
|
||||
or pos.item.questions.all()):
|
||||
|
||||
has_attendee_data = pos.item.admission and (
|
||||
self.request.event.settings.attendee_names_asked
|
||||
or self.request.event.settings.attendee_emails_asked
|
||||
)
|
||||
|
||||
if answers and (has_attendee_data or pos.item.questions.all()):
|
||||
return i, pos.pk, 0, 0, 0, 0,
|
||||
return 0, 0, pos.item_id, pos.variation_id, pos.price, (pos.voucher_id or 0)
|
||||
|
||||
|
||||
@@ -45,6 +45,9 @@ class QuestionsViewMixin:
|
||||
if k == 'attendee_name':
|
||||
form.pos.attendee_name = v if v != '' else None
|
||||
form.pos.save()
|
||||
elif k == 'attendee_email':
|
||||
form.pos.attendee_email = v if v != '' else None
|
||||
form.pos.save()
|
||||
elif k.startswith('question_') and v is not None:
|
||||
field = form.fields[k]
|
||||
if hasattr(field, 'answer'):
|
||||
|
||||
Reference in New Issue
Block a user