Reduced maximum McCabe function complexity by one

This commit is contained in:
Raphael Michel
2015-06-28 17:12:27 +02:00
parent 1f08dfda5c
commit bf6dca3e93
5 changed files with 57 additions and 52 deletions

View File

@@ -79,6 +79,7 @@ def availability_handler(sender, **kwargs):
continue
# Walk through all restriction objects applied to this item
prices = []
for restriction in restrictions:
applied_to = list(restriction.variations.current.all())
@@ -91,12 +92,9 @@ def availability_handler(sender, **kwargs):
if restriction.timeframe_from <= now() <= restriction.timeframe_to:
# Selling this item is currently possible
available = True
# If multiple time frames are currently active, make sure to
# get the cheapest price:
if (restriction.price is not None
and (price is None or restriction.price < price)):
price = restriction.price
prices.append(restriction.price)
price = min([p for p in prices if p is not None])
v['available'] = available
v['price'] = price
cache.set(