Allow ticket output methods to opt-out from ZIP generation

This commit is contained in:
Raphael Michel
2017-07-14 17:32:16 +02:00
parent 7d9e642f24
commit 42287b92f1
4 changed files with 19 additions and 5 deletions

View File

@@ -58,6 +58,8 @@ The output class
.. autoattribute:: is_enabled .. autoattribute:: is_enabled
.. autoattribute:: multi_download_enabled
.. autoattribute:: settings_form_fields .. autoattribute:: settings_form_fields
.. automethod:: settings_content_render .. automethod:: settings_content_render

View File

@@ -32,6 +32,14 @@ class BaseTicketOutput:
""" """
return self.settings.get('_enabled', as_type=bool) return self.settings.get('_enabled', as_type=bool)
@property
def multi_download_enabled(self) -> bool:
"""
Returns whether or not the ``generate_order`` method may be called. Returns
``True`` by default.
"""
return True
def generate(self, position: OrderPosition) -> Tuple[str, str, str]: def generate(self, position: OrderPosition) -> Tuple[str, str, str]:
""" """
This method should generate the download file and return a tuple consisting of a This method should generate the download file and return a tuple consisting of a

View File

@@ -73,14 +73,16 @@
You can download your tickets using the buttons below. Please have your ticket ready when entering the event. You can download your tickets using the buttons below. Please have your ticket ready when entering the event.
{% endblocktrans %} {% endblocktrans %}
</div> </div>
{% if cart.positions|length > 1 %} {% if cart.positions|length > 1 and can_download_multi %}
<p> <p>
{% trans "Download all tickets at once:" %} {% trans "Download all tickets at once:" %}
{% for b in download_buttons %} {% for b in download_buttons %}
<a href="{% eventurl event "presale:event.order.download.combined" secret=order.secret order=order.code output=b.identifier %}" {% if b.multi %}
class="btn btn-default btn-sm" data-asyncdownload> <a href="{% eventurl event "presale:event.order.download.combined" secret=order.secret order=order.code output=b.identifier %}"
<span class="fa fa-download"></span> {{ b.text }} class="btn btn-default btn-sm" data-asyncdownload>
</a> <span class="fa fa-download"></span> {{ b.text }}
</a>
{% endif %}
{% endfor %} {% endfor %}
</p> </p>
{% endif %} {% endif %}

View File

@@ -76,6 +76,7 @@ class OrderDetails(EventViewMixin, OrderDetailMixin, CartMixin, TemplateView):
buttons.append({ buttons.append({
'text': provider.download_button_text or 'Download', 'text': provider.download_button_text or 'Download',
'identifier': provider.identifier, 'identifier': provider.identifier,
'multi': provider.multi_download_enabled
}) })
return buttons return buttons
@@ -93,6 +94,7 @@ class OrderDetails(EventViewMixin, OrderDetailMixin, CartMixin, TemplateView):
) and self.order.status == Order.STATUS_PAID ) and self.order.status == Order.STATUS_PAID
) )
ctx['download_buttons'] = self.download_buttons ctx['download_buttons'] = self.download_buttons
ctx['can_download_multi'] = any([b['multi'] for b in self.download_buttons])
ctx['cart'] = self.get_cart( ctx['cart'] = self.get_cart(
answers=True, downloads=ctx['can_download'], answers=True, downloads=ctx['can_download'],
queryset=self.order.positions.all(), queryset=self.order.positions.all(),