Added products that require a voucher to be bought/shown

This commit is contained in:
Raphael Michel
2016-07-28 19:52:07 +02:00
parent 03a56f81ca
commit f91c95b1bc
10 changed files with 111 additions and 3 deletions

View File

@@ -174,7 +174,13 @@
{% endblocktrans %}</small>
{% endif %}
</div>
{% if item.cached_availability.0 == 100 %}
{% if item.require_voucher %}
<div class="col-md-2 col-xs-6 availability-box unavailable">
<small>
{% trans "Enter a voucher code below to buy this ticket." %}
</small>
</div>
{% elif item.cached_availability.0 == 100 %}
<div class="col-md-2 col-xs-6 availability-box available">
<input type="number" class="form-control input-item-count" placeholder="0" min="0"
max="{{ item.order_max }}" name="item_{{ item.id }}">

View File

@@ -154,12 +154,15 @@ class RedeemView(EventViewMixin, TemplateView):
& Q(Q(available_until__isnull=True) | Q(available_until__gte=now()))
)
vouchq = Q(hide_without_voucher=False)
if self.voucher.item_id:
vouchq |= Q(pk=self.voucher.item_id)
items = items.filter(pk=self.voucher.item_id)
elif self.voucher.quota_id:
items = items.filter(quotas__in=[self.voucher.quota_id])
items = items.select_related(
items = items.filter(vouchq).select_related(
'category', # for re-grouping
).prefetch_related(
'quotas', 'variations__quotas', 'quotas__event' # for .availability()

View File

@@ -31,6 +31,7 @@ class EventIndex(EventViewMixin, CartMixin, TemplateView):
Q(active=True)
& Q(Q(available_from__isnull=True) | Q(available_from__lte=now()))
& Q(Q(available_until__isnull=True) | Q(available_until__gte=now()))
& Q(hide_without_voucher=False)
).select_related(
'category', # for re-grouping
).prefetch_related(