forked from CGM_Public/pretix_original
Clarify show_vouchers constraint with subevents
This commit is contained in:
@@ -252,7 +252,7 @@
|
|||||||
<div class="col-md-3 col-xs-6 col-md-offset-3 price">
|
<div class="col-md-3 col-xs-6 col-md-offset-3 price">
|
||||||
<strong>{{ cart.total|money:event.currency }}</strong>
|
<strong>{{ cart.total|money:event.currency }}</strong>
|
||||||
|
|
||||||
{% if editable and show_vouchers and not cart.all_with_voucher %}
|
{% if editable and vouchers_exist and not cart.all_with_voucher %}
|
||||||
<br>
|
<br>
|
||||||
<a class="js-only apply-voucher-toggle" href="#">
|
<a class="js-only apply-voucher-toggle" href="#">
|
||||||
<span class="fa fa-tag"></span> {% trans "Redeem a voucher" %}
|
<span class="fa fa-tag"></span> {% trans "Redeem a voucher" %}
|
||||||
@@ -273,4 +273,4 @@
|
|||||||
{% endif %}
|
{% endif %}
|
||||||
</div>
|
</div>
|
||||||
<div class="clearfix"></div>
|
<div class="clearfix"></div>
|
||||||
</div>
|
</div>
|
||||||
|
|||||||
@@ -306,6 +306,13 @@ class EventIndex(EventViewMixin, EventListMixin, CartMixin, TemplateView):
|
|||||||
|
|
||||||
def get_context_data(self, **kwargs):
|
def get_context_data(self, **kwargs):
|
||||||
context = super().get_context_data(**kwargs)
|
context = super().get_context_data(**kwargs)
|
||||||
|
|
||||||
|
# Show voucher option if an event is selected and vouchers exist
|
||||||
|
vouchers_exist = self.request.event.cache.get('vouchers_exist')
|
||||||
|
if vouchers_exist is None:
|
||||||
|
vouchers_exist = self.request.event.vouchers.exists()
|
||||||
|
self.request.event.cache.set('vouchers_exist', vouchers_exist)
|
||||||
|
|
||||||
if not self.request.event.has_subevents or self.subevent:
|
if not self.request.event.has_subevents or self.subevent:
|
||||||
# Fetch all items
|
# Fetch all items
|
||||||
items, display_add_to_cart = get_grouped_items(self.request.event, self.subevent,
|
items, display_add_to_cart = get_grouped_items(self.request.event, self.subevent,
|
||||||
@@ -316,14 +323,11 @@ class EventIndex(EventViewMixin, EventListMixin, CartMixin, TemplateView):
|
|||||||
context['items_by_category'] = item_group_by_category(items)
|
context['items_by_category'] = item_group_by_category(items)
|
||||||
context['display_add_to_cart'] = display_add_to_cart
|
context['display_add_to_cart'] = display_add_to_cart
|
||||||
|
|
||||||
# Show voucher option if an event is selected and vouchers exist
|
|
||||||
vouchers_exist = self.request.event.cache.get('vouchers_exist')
|
|
||||||
if vouchers_exist is None:
|
|
||||||
vouchers_exist = self.request.event.vouchers.exists()
|
|
||||||
self.request.event.cache.set('vouchers_exist', vouchers_exist)
|
|
||||||
context['show_vouchers'] = vouchers_exist
|
context['show_vouchers'] = vouchers_exist
|
||||||
|
context['vouchers_exist'] = vouchers_exist
|
||||||
else:
|
else:
|
||||||
context['show_vouchers'] = False
|
context['show_vouchers'] = False
|
||||||
|
context['vouchers_exist'] = vouchers_exist
|
||||||
|
|
||||||
context['ev'] = self.subevent or self.request.event
|
context['ev'] = self.subevent or self.request.event
|
||||||
context['subevent'] = self.subevent
|
context['subevent'] = self.subevent
|
||||||
|
|||||||
Reference in New Issue
Block a user