mirror of
https://github.com/pretix/pretix.git
synced 2026-08-12 11:07:02 +00:00
Move checks to describe function
This commit is contained in:
@@ -3526,11 +3526,30 @@ class InvoiceAddress(models.Model):
|
||||
})
|
||||
return d
|
||||
|
||||
def describe_transmission(self):
|
||||
def describe_transmission(self, event=None):
|
||||
# we only need an explicit event if the order is not yet created and we do not want to show unnecessary data to customers
|
||||
from pretix.base.invoicing.transmission import transmission_types
|
||||
data = []
|
||||
|
||||
t, __ = transmission_types.get(identifier=self.transmission_type)
|
||||
t, m = transmission_types.get(identifier=self.transmission_type)
|
||||
|
||||
d_event = self.order.event if self.order else event
|
||||
# reusing hack from questions.py for default transmission -- this should at least be fast
|
||||
if d_event:
|
||||
if (
|
||||
t.identifier == "email" and
|
||||
m in ("transmission_email_other", "transmission_email_address") and
|
||||
(
|
||||
d_event.settings.invoice_generate == "False" or
|
||||
not d_event.settings.invoice_email_attachment
|
||||
)
|
||||
):
|
||||
return data
|
||||
|
||||
# we also don't show transmission data if we never showed the corresponding form fields
|
||||
if not t.invoice_address_form_fields_visible(country=self.country, is_business=self.is_business):
|
||||
return data
|
||||
|
||||
data.append((_("Transmission type"), t.public_name))
|
||||
form_data = t.transmission_info_to_form_data(self.transmission_info or {})
|
||||
for k, f in t.invoice_address_form_fields.items():
|
||||
|
||||
@@ -56,7 +56,6 @@ from django.utils.translation import (
|
||||
from django.views.generic.base import TemplateResponseMixin
|
||||
from django_scopes import scopes_disabled
|
||||
|
||||
from pretix.base.invoicing.transmission import transmission_types
|
||||
from pretix.base.models import Customer, Membership, Order
|
||||
from pretix.base.models.items import Question
|
||||
from pretix.base.models.orders import (
|
||||
@@ -1507,20 +1506,6 @@ class ConfirmStep(CartMixin, AsyncAction, TemplateFlowStep):
|
||||
label = pgettext_lazy('checkoutflow', 'Review order')
|
||||
icon = 'eye'
|
||||
|
||||
def _default_invisible(self, transmission_type):
|
||||
# reusing hack from questions.py for default transmission -- this should at least be fast
|
||||
for k in transmission_type.invoice_address_form_fields.keys():
|
||||
if (
|
||||
transmission_type.identifier == "email" and
|
||||
k in ("transmission_email_other", "transmission_email_address") and
|
||||
(
|
||||
self.event.settings.invoice_generate == "False" or
|
||||
not self.event.settings.invoice_email_attachment
|
||||
)
|
||||
):
|
||||
return True
|
||||
return False
|
||||
|
||||
def is_applicable(self, request):
|
||||
return True
|
||||
|
||||
@@ -1560,14 +1545,7 @@ class ConfirmStep(CartMixin, AsyncAction, TemplateFlowStep):
|
||||
ctx['invoice_address_asked'] = self.address_asked
|
||||
ctx['customer'] = self.cart_customer
|
||||
|
||||
transmission_fields = []
|
||||
transmission_type, __ = transmission_types.get(identifier=self.invoice_address.transmission_type)
|
||||
if not self._default_invisible(transmission_type) and transmission_type.invoice_address_form_fields_visible(
|
||||
country=self.invoice_address.country, is_business=self.invoice_address.is_business
|
||||
):
|
||||
for line in self.invoice_address.describe_transmission():
|
||||
transmission_fields.append(line)
|
||||
ctx['transmission_fields'] = transmission_fields
|
||||
ctx['transmission_fields'] = self.invoice_address.describe_transmission(self.event)
|
||||
|
||||
self.cart_session['shown_total'] = str(ctx['cart']['total'])
|
||||
|
||||
|
||||
Reference in New Issue
Block a user