Allow to hide all sold out items

This commit is contained in:
Raphael Michel
2019-07-18 15:00:39 +02:00
parent a99616b1e0
commit 6d12b3780c
5 changed files with 41 additions and 4 deletions

View File

@@ -120,7 +120,10 @@ def get_grouped_items(event, subevent=None, voucher=None, channel='web', require
max_per_order = item.max_per_order or int(event.settings.max_items_per_order)
if not item.has_variations:
item._remove = not bool(item._subevent_quotas)
item._remove = False
if not bool(item._subevent_quotas):
item._remove = True
continue
if voucher and (voucher.allow_ignore_quota or voucher.block_quota):
item.cached_availability = (
@@ -131,6 +134,10 @@ def get_grouped_items(event, subevent=None, voucher=None, channel='web', require
item.check_quotas(subevent=subevent, _cache=quota_cache, include_bundled=True)
)
if event.settings.hide_sold_out and item.cached_availability[0] < Quota.AVAILABILITY_RESERVED:
item._remove = True
continue
item.order_max = min(
item.cached_availability[1]
if item.cached_availability[1] is not None else sys.maxsize,
@@ -203,6 +210,10 @@ def get_grouped_items(event, subevent=None, voucher=None, channel='web', require
)
]
if event.settings.hide_sold_out:
item.available_variations = [v for v in item.available_variations
if v.cached_availability[0] >= Quota.AVAILABILITY_RESERVED]
if voucher and voucher.variation_id:
item.available_variations = [v for v in item.available_variations
if v.pk == voucher.variation_id]