mirror of
https://github.com/pretix/pretix.git
synced 2026-08-09 10:37:50 +00:00
Display invoice transmission in the (re)transmit button tooltip (Z#23241800)
This commit is contained in:
@@ -82,6 +82,14 @@ class EmailTransmissionType(TransmissionType):
|
||||
}
|
||||
return {}
|
||||
|
||||
def describe_invoice_destination(self, invoice):
|
||||
info = (invoice.invoice_to_transmission_info or {})
|
||||
if info.get("transmission_email_address"):
|
||||
recipient = info["transmission_email_address"]
|
||||
else:
|
||||
recipient = invoice.order.email
|
||||
return _("Via Email to {recipient}").format(recipient=recipient)
|
||||
|
||||
|
||||
@transmission_providers.new()
|
||||
class EmailTransmissionProvider(TransmissionProvider):
|
||||
|
||||
@@ -123,6 +123,19 @@ class TransmissionType:
|
||||
data.append((f.label, v))
|
||||
return data
|
||||
|
||||
def describe_invoice_destination(self, invoice):
|
||||
info = self.describe_info(
|
||||
invoice.invoice_to_transmission_info or {},
|
||||
invoice.invoice_to_country,
|
||||
invoice.invoice_to_is_business,
|
||||
)
|
||||
destination = ", ".join(f"{k}: {v}" for (k, v) in info)
|
||||
return "{via} {method}{destination}".format(
|
||||
via=_("Via"),
|
||||
method=self.verbose_name,
|
||||
destination=f" ({destination})" if destination else "",
|
||||
)
|
||||
|
||||
def pdf_watermark(self) -> Optional[str]:
|
||||
"""
|
||||
Return a watermark that should be rendered across the PDF file.
|
||||
|
||||
@@ -398,6 +398,10 @@ class Invoice(models.Model):
|
||||
from pretix.base.invoicing.transmission import transmission_types
|
||||
return transmission_types.get(identifier=self.transmission_type)[0]
|
||||
|
||||
@property
|
||||
def transmission_type_destination_description(self):
|
||||
return self.transmission_type_instance.describe_invoice_destination(self)
|
||||
|
||||
def set_transmission_failed(self, provider, data):
|
||||
self.transmission_status = Invoice.TRANSMISSION_STATUS_FAILED
|
||||
self.transmission_date = now()
|
||||
|
||||
@@ -357,7 +357,7 @@
|
||||
action="{% url "control:event.order.retransmitinvoice" event=request.event.slug organizer=request.event.organizer.slug code=order.code id=i.pk %}">
|
||||
{% csrf_token %}
|
||||
<button class="btn btn-default btn-xs" data-toggle="tooltip"
|
||||
title="{{ i.transmission_type_instance.verbose_name }}">
|
||||
title="{{ i.transmission_type_destination_description }}">
|
||||
{% if i.transmission_status == "pending" %}
|
||||
{% trans "Transmit" %}
|
||||
{% else %}
|
||||
|
||||
Reference in New Issue
Block a user