Allow to enable ticket downloads for pending orders

This commit is contained in:
Raphael Michel
2018-10-03 12:11:06 +02:00
parent 4b8d4b4792
commit 0dbcfdc5ac
10 changed files with 93 additions and 46 deletions

View File

@@ -84,28 +84,28 @@
</div>
</div>
{% endif %}
{% if order.status == 'p' and event.settings.ticket_download %}
{% if can_download and download_buttons %}
<div class="alert alert-info">
{% 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>
{% trans "Download all tickets at once:" %}
{% for b in download_buttons %}
{% if b.multi %}
<a href="{% eventurl event "presale:event.order.download.combined" secret=order.secret order=order.code output=b.identifier %}"
class="btn btn-sm {% if b.identifier == "pdf" %}btn-primary{% else %}btn-default{% endif %}"
data-asyncdownload>
<span class="fa {{ b.icon }}"></span> {{ b.text }}
</a>
{% endif %}
{% endfor %}
</p>
{% endif %}
{% elif not download_buttons and ticket_download_date %}
{% if can_download and download_buttons %}
<div class="alert alert-info">
{% 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>
{% trans "Download all tickets at once:" %}
{% for b in download_buttons %}
{% if b.multi %}
<a href="{% eventurl event "presale:event.order.download.combined" secret=order.secret order=order.code output=b.identifier %}"
class="btn btn-sm {% if b.identifier == "pdf" %}btn-primary{% else %}btn-default{% endif %}"
data-asyncdownload>
<span class="fa {{ b.icon }}"></span> {{ b.text }}
</a>
{% endif %}
{% endfor %}
</p>
{% endif %}
{% elif not download_buttons and ticket_download_date %}
{% if order.status == 'p' %}
<div class="alert alert-info">
{% blocktrans trimmed with date=ticket_download_date|date:"SHORT_DATE_FORMAT" %}
You will be able to download your tickets here starting on {{ date }}.

View File

@@ -95,13 +95,7 @@ class OrderDetails(EventViewMixin, OrderDetailMixin, CartMixin, TemplateView):
can_download = all([r for rr, r in allow_ticket_download.send(self.request.event, order=self.order)])
if self.request.event.settings.ticket_download_date:
ctx['ticket_download_date'] = self.order.ticket_download_date
ctx['can_download'] = (
can_download and self.request.event.settings.ticket_download
and (
self.request.event.settings.ticket_download_date is None
or now() > self.order.ticket_download_date
) and self.order.status == Order.STATUS_PAID
)
ctx['can_download'] = can_download and self.order.ticket_download_available
ctx['download_buttons'] = self.download_buttons
ctx['cart'] = self.get_cart(
answers=True, downloads=ctx['can_download'],
@@ -682,12 +676,8 @@ class OrderDownload(EventViewMixin, OrderDetailMixin, View):
return self.error(_('You requested an invalid ticket output type.'))
if not self.order or ('position' in kwargs and not self.order_position):
raise Http404(_('Unknown order code or not authorized to access this order.'))
if self.order.status != Order.STATUS_PAID:
return self.error(_('Order is not paid.'))
if (not self.request.event.settings.ticket_download
or (self.request.event.settings.ticket_download_date is not None
and now() < self.order.ticket_download_date)):
return self.error(_('Ticket download is not (yet) enabled.'))
if not self.order.ticket_download_available:
return self.error(_('Ticket download is not (yet) enabled for this order.'))
if 'position' in kwargs and (self.order_position.addon_to and not self.request.event.settings.ticket_download_addons):
return self.error(_('Ticket download is not enabled for add-on products.'))
if 'position' in kwargs and (not self.order_position.item.admission and not self.request.event.settings.ticket_download_nonadm):