forked from CGM_Public/pretix_original
Checkout: improve heuristic to open invoice-panel (#3545)
This commit is contained in:
committed by
GitHub
parent
38173e3a54
commit
21864885cb
@@ -1026,6 +1026,25 @@ class QuestionsStep(QuestionsViewMixin, CartMixin, TemplateFlowStep):
|
|||||||
ctx['cart_session'] = self.cart_session
|
ctx['cart_session'] = self.cart_session
|
||||||
ctx['invoice_address_asked'] = self.address_asked
|
ctx['invoice_address_asked'] = self.address_asked
|
||||||
|
|
||||||
|
def reduce_initial(v):
|
||||||
|
if isinstance(v, dict):
|
||||||
|
# try to flatten objects such as name_parts to a single string to determine whether they have any value set
|
||||||
|
return ''.join([v for k, v in v.items() if not k.startswith('_')])
|
||||||
|
else:
|
||||||
|
return v
|
||||||
|
|
||||||
|
def is_form_filled(form, ignore_keys=()):
|
||||||
|
return any([reduce_initial(v) for k, v in form.initial.items() if k not in ignore_keys])
|
||||||
|
|
||||||
|
ctx['invoice_address_open'] = (
|
||||||
|
self.request.event.settings.invoice_address_required or
|
||||||
|
self.request.event.settings.invoice_name_required or
|
||||||
|
'invoice' in self.request.GET or
|
||||||
|
# Checking for self.invoice_address.pk is not enough as when an invoice_address has been added and later edited to be empty, it’s not None.
|
||||||
|
# So check initial values as invoice_form can receive pre-filled values from invoice_address, widget-data or overwrites from plug-ins.
|
||||||
|
is_form_filled(self.invoice_form, ignore_keys=('is_business', 'country'))
|
||||||
|
)
|
||||||
|
|
||||||
if self.cart_customer:
|
if self.cart_customer:
|
||||||
if self.address_asked:
|
if self.address_asked:
|
||||||
addresses = self.cart_customer.stored_addresses.all()
|
addresses = self.cart_customer.stored_addresses.all()
|
||||||
|
|||||||
@@ -76,7 +76,7 @@
|
|||||||
<div class="panel-heading">
|
<div class="panel-heading">
|
||||||
<h3 class="panel-title">
|
<h3 class="panel-title">
|
||||||
{% trans "Invoice information" %}
|
{% trans "Invoice information" %}
|
||||||
<a href="{% eventurl request.event "presale:event.checkout" step="questions" cart_namespace=cart_namespace|default_if_none:"" %}?invoice=1" aria-label="{% trans "Modify invoice information" %}" class="h6">
|
<a href="{% eventurl request.event "presale:event.checkout" step="questions" cart_namespace=cart_namespace|default_if_none:"" %}?invoice=1#invoice-details" aria-label="{% trans "Modify invoice information" %}" class="h6">
|
||||||
<span class="fa fa-edit" aria-hidden="true"></span>{% trans "Modify" %}
|
<span class="fa fa-edit" aria-hidden="true"></span>{% trans "Modify" %}
|
||||||
</a>
|
</a>
|
||||||
</h3>
|
</h3>
|
||||||
|
|||||||
@@ -34,7 +34,7 @@
|
|||||||
</div>
|
</div>
|
||||||
</details>
|
</details>
|
||||||
{% if invoice_address_asked %}
|
{% if invoice_address_asked %}
|
||||||
<details class="panel panel-default" {% if event.settings.invoice_address_required or event.settings.invoice_name_required %}open{% endif %}>
|
<details class="panel panel-default" {% if invoice_address_open %}open{% endif %} id="invoice-details">
|
||||||
<summary class="panel-heading">
|
<summary class="panel-heading">
|
||||||
<h3 class="panel-title">
|
<h3 class="panel-title">
|
||||||
<strong>{% trans "Invoice information" %}{% if not event.settings.invoice_address_required and not event.settings.invoice_name_required %}
|
<strong>{% trans "Invoice information" %}{% if not event.settings.invoice_address_required and not event.settings.invoice_name_required %}
|
||||||
|
|||||||
Reference in New Issue
Block a user