mirror of
https://github.com/pretix/pretix.git
synced 2026-05-06 15:24:02 +00:00
More visible download buttons for single tickets
This commit is contained in:
@@ -162,6 +162,13 @@ class BaseTicketOutput:
|
||||
"""
|
||||
return _('Download ticket')
|
||||
|
||||
@property
|
||||
def long_download_button_text(self) -> str:
|
||||
"""
|
||||
The text on the large download button in the frontend.
|
||||
"""
|
||||
return self.download_button_text
|
||||
|
||||
@property
|
||||
def multi_download_button_text(self) -> str:
|
||||
"""
|
||||
|
||||
@@ -29,6 +29,7 @@ class PdfTicketOutput(BaseTicketOutput):
|
||||
verbose_name = _('PDF output')
|
||||
download_button_text = _('PDF')
|
||||
multi_download_button_text = _('Download tickets (PDF)')
|
||||
long_download_button_text = _('Download ticket (PDF)')
|
||||
|
||||
def __init__(self, event, override_layout=None, override_background=None):
|
||||
self.override_layout = override_layout
|
||||
|
||||
@@ -5,24 +5,37 @@
|
||||
{% blocktrans trimmed %}
|
||||
You can download your tickets using the buttons below. Please have your ticket ready when entering the event.
|
||||
{% endblocktrans %}
|
||||
</div>
|
||||
{% if cart.positions|length > 1 and can_download_multi %}
|
||||
<p class="info-download">
|
||||
{% trans "Download all tickets at once:" %}
|
||||
{% for b in download_buttons %}
|
||||
{% if b.multi %}
|
||||
<form action="{% eventurl event "presale:event.order.download.combined" secret=order.secret order=order.code output=b.identifier %}"
|
||||
method="post" data-asynctask data-asynctask-download class="download-btn-form">
|
||||
{% if cart.positions|length > 1 and can_download_multi %}
|
||||
<p class="info-download">
|
||||
{% trans "Download all tickets at once:" %}
|
||||
{% for b in download_buttons %}
|
||||
{% if b.multi %}
|
||||
<form action="{% eventurl event "presale:event.order.download.combined" secret=order.secret order=order.code output=b.identifier %}"
|
||||
method="post" data-asynctask data-asynctask-download class="download-btn-form">
|
||||
{% csrf_token %}
|
||||
<button type="submit"
|
||||
class="btn btn-lg {% if b.identifier == "pdf" %}btn-primary{% else %}btn-default{% endif %}">
|
||||
<span class="fa {{ b.icon }}"></span> {{ b.multi_text }}
|
||||
</button>
|
||||
</form>
|
||||
{% endif %}
|
||||
{% endfor %}
|
||||
</p>
|
||||
{% elif tickets_with_download|length == 1 %}
|
||||
<p class="info-download">
|
||||
{% for b in download_buttons %}
|
||||
<form action="{% if position_page and tickets_with_download.0.addon_to %}{% eventurl event "presale:event.order.position.download" secret=tickets_with_download.0.addon_to.web_secret order=order.code output=b.identifier pid=tickets_with_download.0.pk position=tickets_with_download.0.addon_to.positionid %}{% elif position_page %}{% eventurl event "presale:event.order.position.download" secret=tickets_with_download.0.web_secret order=order.code output=b.identifier pid=tickets_with_download.0.pk position=tickets_with_download.0.positionid %}{% else %}{% eventurl event "presale:event.order.download" secret=order.secret order=order.code output=b.identifier position=tickets_with_download.0.pk %}{% endif %}"
|
||||
method="post" data-asynctask data-asynctask-download class="download-btn-form{% if b.javascript_required %} requirejs{% endif %}">
|
||||
{% csrf_token %}
|
||||
<button type="submit"
|
||||
class="btn btn-lg {% if b.identifier == "pdf" %}btn-primary{% else %}btn-default{% endif %}">
|
||||
<span class="fa {{ b.icon }}"></span> {{ b.multi_text }}
|
||||
<span class="fa {{ b.icon }}"></span> {{ b.long_text }}
|
||||
</button>
|
||||
</form>
|
||||
{% endif %}
|
||||
{% endfor %}
|
||||
</p>
|
||||
{% endif %}
|
||||
{% endfor %}
|
||||
</p>
|
||||
{% endif %}
|
||||
</div>
|
||||
{% elif not download_buttons and ticket_download_date %}
|
||||
{% if order.status == 'p' %}
|
||||
<div class="alert alert-info info-download">
|
||||
|
||||
@@ -162,6 +162,7 @@ class OrderDetails(EventViewMixin, OrderDetailMixin, CartMixin, TicketPageMixin,
|
||||
buttons.append({
|
||||
'text': provider.download_button_text or 'Download',
|
||||
'multi_text': provider.multi_download_button_text or 'Download',
|
||||
'long_text': provider.long_download_button_text or 'Download',
|
||||
'icon': provider.download_button_icon or 'fa-download',
|
||||
'identifier': provider.identifier,
|
||||
'multi': provider.multi_download_enabled,
|
||||
@@ -176,6 +177,7 @@ class OrderDetails(EventViewMixin, OrderDetailMixin, CartMixin, TicketPageMixin,
|
||||
queryset=self.order.positions.prefetch_related('issued_gift_cards').select_related('tax_rule'),
|
||||
order=self.order
|
||||
)
|
||||
ctx['tickets_with_download'] = [p for p in ctx['cart']['positions'] if p.generate_ticket]
|
||||
ctx['can_download_multi'] = any([b['multi'] for b in self.download_buttons]) and (
|
||||
[p.generate_ticket for p in ctx['cart']['positions']].count(True) > 1
|
||||
)
|
||||
@@ -256,6 +258,8 @@ class OrderPositionDetails(EventViewMixin, OrderPositionDetailMixin, CartMixin,
|
||||
'icon': provider.download_button_icon or 'fa-download',
|
||||
'identifier': provider.identifier,
|
||||
'multi': provider.multi_download_enabled,
|
||||
'multi_text': provider.multi_download_button_text or 'Download',
|
||||
'long_text': provider.long_download_button_text or 'Download',
|
||||
'javascript_required': provider.javascript_required
|
||||
})
|
||||
return buttons
|
||||
@@ -271,6 +275,7 @@ class OrderPositionDetails(EventViewMixin, OrderPositionDetailMixin, CartMixin,
|
||||
),
|
||||
order=self.order
|
||||
)
|
||||
ctx['tickets_with_download'] = [p for p in ctx['cart']['positions'] if p.generate_ticket]
|
||||
return ctx
|
||||
|
||||
|
||||
|
||||
@@ -227,3 +227,6 @@ h2.subevent-head {
|
||||
#cancel-fee-custom-link {
|
||||
margin-bottom: 20px;
|
||||
}
|
||||
.info-download {
|
||||
margin-top: 15px;
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user