Fixes bug in product and category, and ceiling enabling conditions

This commit is contained in:
Christopher Neugebauer 2016-04-02 20:11:31 +11:00
parent 8796670328
commit 2cbda9172f
2 changed files with 12 additions and 3 deletions

View file

@ -158,7 +158,7 @@ class CategoryConditionController(ConditionController):
category=self.condition.enabling_category, category=self.condition.enabling_category,
) )
products_count = rego.ProductItem.objects.filter( products_count = rego.ProductItem.objects.filter(
cart=carts, cart__in=carts,
product__in=enabling_products, product__in=enabling_products,
).count() ).count()
return products_count > 0 return products_count > 0
@ -177,7 +177,7 @@ class ProductConditionController(ConditionController):
carts = rego.Cart.objects.filter(user=user, released=False) carts = rego.Cart.objects.filter(user=user, released=False)
products_count = rego.ProductItem.objects.filter( products_count = rego.ProductItem.objects.filter(
cart=carts, cart__in=carts,
product__in=self.condition.enabling_products.all(), product__in=self.condition.enabling_products.all(),
).count() ).count()
return products_count > 0 return products_count > 0
@ -247,7 +247,7 @@ class TimeOrStockLimitConditionController(ConditionController):
product_items = rego.ProductItem.objects.filter( product_items = rego.ProductItem.objects.filter(
product__in=self._products().all(), product__in=self._products().all(),
) )
product_items = product_items.filter(cart=reserved_carts) product_items = product_items.filter(cart__in=reserved_carts)
count = product_items.aggregate(Sum("quantity"))["quantity__sum"] or 0 count = product_items.aggregate(Sum("quantity"))["quantity__sum"] or 0

View file

@ -72,6 +72,15 @@ class RegistrationCartTestCase(SetTimeMixin, TestCase):
cls.PROD_4.price = Decimal("5.00") cls.PROD_4.price = Decimal("5.00")
cls.PROD_4.save() cls.PROD_4.save()
# Burn through some carts -- this made some past EC tests fail
current_cart = CartController.for_user(cls.USER_1)
current_cart.cart.active = False
current_cart.cart.save()
current_cart = CartController.for_user(cls.USER_2)
current_cart.cart.active = False
current_cart.cart.save()
@classmethod @classmethod
def make_ceiling(cls, name, limit=None, start_time=None, end_time=None): def make_ceiling(cls, name, limit=None, start_time=None, end_time=None):
limit_ceiling = rego.TimeOrStockLimitEnablingCondition.objects.create( limit_ceiling = rego.TimeOrStockLimitEnablingCondition.objects.create(