Add constraint for a maximum number of a ticket per order

This commit is contained in:
Raphael Michel
2017-03-24 17:11:48 +01:00
parent 36d6b6f9ab
commit 69faab01b2
10 changed files with 141 additions and 4 deletions

View File

@@ -183,6 +183,8 @@ class RedeemView(EventViewMixin, TemplateView):
if self.voucher.item_id and self.voucher.variation_id:
item.available_variations = [v for v in item.available_variations if v.pk == self.voucher.variation_id]
item.order_max = item.max_per_order or int(self.request.event.settings.max_items_per_order)
item.has_variations = item.variations.exists()
if not item.has_variations:
if self.voucher.allow_ignore_quota or self.voucher.block_quota:

View File

@@ -63,11 +63,12 @@ def get_grouped_items(event):
display_add_to_cart = False
quota_cache = {}
for item in items:
max_per_order = item.max_per_order or int(event.settings.max_items_per_order)
if not item.has_variations:
item.cached_availability = list(item.check_quotas(_cache=quota_cache))
item.order_max = min(item.cached_availability[1]
if item.cached_availability[1] is not None else sys.maxsize,
int(event.settings.max_items_per_order))
max_per_order)
item.price = item.default_price
item.display_price = item.default_price_net if event.settings.display_net_prices else item.price
display_add_to_cart = display_add_to_cart or item.order_max > 0
@@ -76,7 +77,7 @@ def get_grouped_items(event):
var.cached_availability = list(var.check_quotas(_cache=quota_cache))
var.order_max = min(var.cached_availability[1]
if var.cached_availability[1] is not None else sys.maxsize,
int(event.settings.max_items_per_order))
max_per_order)
var.display_price = var.net_price if event.settings.display_net_prices else var.price
display_add_to_cart = display_add_to_cart or var.order_max > 0
if len(item.available_variations) > 0: