From 765076540a5390d1aa70f0a43d31c76716092bf1 Mon Sep 17 00:00:00 2001 From: Raphael Michel Date: Sun, 28 Jun 2015 17:39:58 +0200 Subject: [PATCH] Fixed a bug introduced in 1f08dfd --- doc/development/api/restriction.rst | 5 +++-- src/pretix/plugins/timerestriction/signals.py | 6 ++++-- 2 files changed, 7 insertions(+), 4 deletions(-) diff --git a/doc/development/api/restriction.rst b/doc/development/api/restriction.rst index 255587e4e6..64bfd18501 100644 --- a/doc/development/api/restriction.rst +++ b/doc/development/api/restriction.rst @@ -156,7 +156,6 @@ In our example, the implementation could look like this:: # Therefore, it is only available inside one of the timeframes, but not # without any timeframe available = False - price = None # Make up some unique key for this variation cachekey = 'timerestriction:%d:%s' % ( @@ -190,7 +189,9 @@ In our example, the implementation could look like this:: available = True prices.append(restriction.price) - price = min([p for p in prices if p is not None]) + # Use the lowest of all prices set by restrictions + prices = [p for p in prices if p is not None] + price = min(prices) if prices else None v['available'] = available v['price'] = price diff --git a/src/pretix/plugins/timerestriction/signals.py b/src/pretix/plugins/timerestriction/signals.py index 356d3df2f1..43ff6bddbf 100644 --- a/src/pretix/plugins/timerestriction/signals.py +++ b/src/pretix/plugins/timerestriction/signals.py @@ -60,7 +60,6 @@ def availability_handler(sender, **kwargs): # Therefore, it is only available inside one of the timeframes, but not # without any timeframe available = False - price = None # Make up some unique key for this variation cachekey = 'timerestriction:%s:%s' % ( @@ -94,7 +93,10 @@ def availability_handler(sender, **kwargs): available = True prices.append(restriction.price) - price = min([p for p in prices if p is not None]) + # Use the lowest of all prices set by restrictions + prices = [p for p in prices if p is not None] + price = min(prices) if prices else None + v['available'] = available v['price'] = price cache.set(