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

@@ -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(