forked from CGM_Public/pretix_original
Widget: Allow passing more invoice data fields (#4162)
This commit is contained in:
@@ -339,9 +339,9 @@ Currently, the following attributes are understood by pretix itself:
|
|||||||
``data-attendee-name``, which will pre-fill the last part of the name, whatever that is.
|
``data-attendee-name``, which will pre-fill the last part of the name, whatever that is.
|
||||||
|
|
||||||
* ``data-invoice-address-FIELD`` will pre-fill the corresponding field of the invoice address. Possible values for
|
* ``data-invoice-address-FIELD`` will pre-fill the corresponding field of the invoice address. Possible values for
|
||||||
``FIELD`` are ``company``, ``street``, ``zipcode``, ``city`` and ``country``, as well as fields specified by the
|
``FIELD`` are ``company``, ``street``, ``zipcode``, ``city``, ``country``, ``internal-reference``, ``vat-id``, and
|
||||||
naming scheme such as ``name-title`` or ``name-given-name`` (see above). ``country`` expects a two-character
|
``custom-field``, as well as fields specified by the naming scheme such as ``name-title`` or ``name-given-name``
|
||||||
country code.
|
(see above). ``country`` expects a two-character country code.
|
||||||
|
|
||||||
* If ``data-fix="true"`` is given, the user will not be able to change the other given values later. This currently
|
* If ``data-fix="true"`` is given, the user will not be able to change the other given values later. This currently
|
||||||
only works for the order email address as well as the invoice address. Attendee-level fields and questions can
|
only works for the order email address as well as the invoice address. Attendee-level fields and questions can
|
||||||
|
|||||||
@@ -1171,7 +1171,7 @@ class BaseInvoiceAddressForm(forms.ModelForm):
|
|||||||
self.instance.vat_id_validated = False
|
self.instance.vat_id_validated = False
|
||||||
messages.warning(self.request, e.message)
|
messages.warning(self.request, e.message)
|
||||||
else:
|
else:
|
||||||
raise ValidationError(e.message)
|
raise ValidationError({"vat_id": e.message})
|
||||||
except VATIDTemporaryError as e:
|
except VATIDTemporaryError as e:
|
||||||
self.instance.vat_id_validated = False
|
self.instance.vat_id_validated = False
|
||||||
if self.request and self.vat_warning:
|
if self.request and self.vat_warning:
|
||||||
|
|||||||
@@ -827,6 +827,9 @@ class QuestionsStep(QuestionsViewMixin, CartMixin, TemplateFlowStep):
|
|||||||
'zipcode': wd.get('invoice-address-zipcode', ''),
|
'zipcode': wd.get('invoice-address-zipcode', ''),
|
||||||
'city': wd.get('invoice-address-city', ''),
|
'city': wd.get('invoice-address-city', ''),
|
||||||
'country': wd.get('invoice-address-country', ''),
|
'country': wd.get('invoice-address-country', ''),
|
||||||
|
'internal_reference': wd.get('invoice-address-internal-reference', ''),
|
||||||
|
'custom_field': wd.get('invoice-address-custom-field', ''),
|
||||||
|
'vat_id': wd.get('invoice-address-vat-id', ''),
|
||||||
}
|
}
|
||||||
else:
|
else:
|
||||||
wd_initial = {
|
wd_initial = {
|
||||||
@@ -893,6 +896,15 @@ class QuestionsStep(QuestionsViewMixin, CartMixin, TemplateFlowStep):
|
|||||||
if failed:
|
if failed:
|
||||||
messages.error(request,
|
messages.error(request,
|
||||||
_("We had difficulties processing your input. Please review the errors below."))
|
_("We had difficulties processing your input. Please review the errors below."))
|
||||||
|
if "vat_id" in self.invoice_form.errors:
|
||||||
|
# If an invalid VAT ID was given through the widget together with data-fix="true", let's un-block
|
||||||
|
# the field to prevent a deadlock.
|
||||||
|
widget_data = self.cart_session.get('widget_data', {})
|
||||||
|
if "invoice-address-vat-id" in widget_data:
|
||||||
|
vat_id = widget_data.pop("invoice-address-vat-id", None)
|
||||||
|
self.invoice_form.data["vat_id"] = vat_id
|
||||||
|
self.invoice_form.fields["vat_id"].disabled = False
|
||||||
|
self.cart_session['widget_data'] = widget_data
|
||||||
return self.render()
|
return self.render()
|
||||||
self.cart_session['email'] = self.contact_form.cleaned_data['email']
|
self.cart_session['email'] = self.contact_form.cleaned_data['email']
|
||||||
d = dict(self.contact_form.cleaned_data)
|
d = dict(self.contact_form.cleaned_data)
|
||||||
|
|||||||
Reference in New Issue
Block a user