diff --git a/registrasion/controllers/discount.py b/registrasion/controllers/discount.py index 108ed29b..79785a64 100644 --- a/registrasion/controllers/discount.py +++ b/registrasion/controllers/discount.py @@ -117,12 +117,14 @@ class DiscountController(object): product_clauses = conditions.DiscountForProduct.objects.all() product_clauses = product_clauses.select_related( + "discount", "product", "product__category", ) category_clauses = conditions.DiscountForCategory.objects.all() category_clauses = category_clauses.select_related( "category", + "discount", ) valid_discounts = conditions.DiscountBase.objects.all() diff --git a/registrasion/controllers/flag.py b/registrasion/controllers/flag.py index 879d85f0..29b5be6d 100644 --- a/registrasion/controllers/flag.py +++ b/registrasion/controllers/flag.py @@ -85,6 +85,8 @@ class FlagController(object): # from the categories covered by this condition ids = [product.id for product in products] + + # TODO: This is re-evaluated a lot. all_products = inventory.Product.objects.filter(id__in=ids) cond = ( Q(flagbase_set=condition) | @@ -181,7 +183,7 @@ class FlagController(object): flags = ctrl.pre_filter(flags, user) all_subsets.append(flags) - return itertools.chain(*all_subsets) + return list(itertools.chain(*all_subsets)) ConditionAndRemainder = namedtuple(