From 16ab0d29d6c19a2a98488092e4e33b6870425e29 Mon Sep 17 00:00:00 2001 From: Raphael Michel Date: Sun, 4 Feb 2018 22:15:58 +0100 Subject: [PATCH] Add request argument to contact_form_fields signal --- src/pretix/presale/checkoutflow.py | 3 ++- src/pretix/presale/forms/checkout.py | 3 ++- src/pretix/presale/signals.py | 3 ++- 3 files changed, 6 insertions(+), 3 deletions(-) diff --git a/src/pretix/presale/checkoutflow.py b/src/pretix/presale/checkoutflow.py index 9e5a175e39..18c9deb969 100644 --- a/src/pretix/presale/checkoutflow.py +++ b/src/pretix/presale/checkoutflow.py @@ -312,6 +312,7 @@ class QuestionsStep(QuestionsViewMixin, CartMixin, TemplateFlowStep): initial.update(self.cart_session.get('contact_form_data', {})) return ContactForm(data=self.request.POST if self.request.method == "POST" else None, event=self.request.event, + request=self.request, initial=initial) @cached_property @@ -517,7 +518,7 @@ class ConfirmStep(CartMixin, AsyncAction, TemplateFlowStep): ctx['cart_session'] = self.cart_session ctx['contact_info'] = [] - responses = contact_form_fields.send(self.event) + responses = contact_form_fields.send(self.event, request=self.request) for r, response in sorted(responses, key=lambda r: str(r[0])): for key, value in response.items(): v = self.cart_session.get('contact_form_data', {}).get(key) diff --git a/src/pretix/presale/forms/checkout.py b/src/pretix/presale/forms/checkout.py index b121b01a39..e55cb5cdf1 100644 --- a/src/pretix/presale/forms/checkout.py +++ b/src/pretix/presale/forms/checkout.py @@ -27,6 +27,7 @@ class ContactForm(forms.Form): def __init__(self, *args, **kwargs): self.event = kwargs.pop('event') + self.request = kwargs.pop('request') super().__init__(*args, **kwargs) if self.event.settings.order_email_asked_twice: @@ -35,7 +36,7 @@ class ContactForm(forms.Form): help_text=_('Please enter the same email address again to make sure you typed it correctly.') ) - responses = contact_form_fields.send(self.event) + responses = contact_form_fields.send(self.event, request=self.request) 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 diff --git a/src/pretix/presale/signals.py b/src/pretix/presale/signals.py index d9f540dd7e..cef3b7f718 100644 --- a/src/pretix/presale/signals.py +++ b/src/pretix/presale/signals.py @@ -100,7 +100,8 @@ and by default only asks for the email address. You are supposed to return a dic form fields with globally unique keys. The validated form results will be saved into the ``contact_form_data`` entry of the order's meta_info dictionary. -As with all plugin signals, the ``sender`` keyword argument will contain the event. +As with all plugin signals, the ``sender`` keyword argument will contain the event. A ``request`` +argument will contain the request object. """ question_form_fields = EventPluginSignal(