Fixes tests on Django 1.9
This commit is contained in:
parent
3a6b4125e9
commit
69a65ac3ed
2 changed files with 17 additions and 8 deletions
registrasion/controllers
|
@ -46,10 +46,12 @@ class CategoryConditionController(ConditionController):
|
||||||
|
|
||||||
carts = rego.Cart.objects.filter(user=user, released=False)
|
carts = rego.Cart.objects.filter(user=user, released=False)
|
||||||
enabling_products = rego.Product.objects.filter(
|
enabling_products = rego.Product.objects.filter(
|
||||||
category=self.condition.enabling_category)
|
category=self.condition.enabling_category,
|
||||||
|
)
|
||||||
products = rego.ProductItem.objects.filter(
|
products = rego.ProductItem.objects.filter(
|
||||||
cart=carts,
|
cart=carts,
|
||||||
product=enabling_products)
|
product__in=enabling_products,
|
||||||
|
)
|
||||||
return len(products) > 0
|
return len(products) > 0
|
||||||
|
|
||||||
|
|
||||||
|
@ -67,7 +69,8 @@ class ProductConditionController(ConditionController):
|
||||||
carts = rego.Cart.objects.filter(user=user, released=False)
|
carts = rego.Cart.objects.filter(user=user, released=False)
|
||||||
products = rego.ProductItem.objects.filter(
|
products = rego.ProductItem.objects.filter(
|
||||||
cart=carts,
|
cart=carts,
|
||||||
product=self.condition.enabling_products.all())
|
product__in=self.condition.enabling_products.all(),
|
||||||
|
)
|
||||||
return len(products) > 0
|
return len(products) > 0
|
||||||
|
|
||||||
|
|
||||||
|
@ -111,12 +114,12 @@ class TimeOrStockLimitConditionController(ConditionController):
|
||||||
list products differently to discounts. '''
|
list products differently to discounts. '''
|
||||||
if isinstance(self.ceiling, rego.TimeOrStockLimitEnablingCondition):
|
if isinstance(self.ceiling, rego.TimeOrStockLimitEnablingCondition):
|
||||||
category_products = rego.Product.objects.filter(
|
category_products = rego.Product.objects.filter(
|
||||||
category=self.ceiling.categories.all()
|
category=self.ceiling.categories.all(),
|
||||||
)
|
)
|
||||||
return self.ceiling.products.all() | category_products
|
return self.ceiling.products.all() | category_products
|
||||||
else:
|
else:
|
||||||
categories = rego.Category.objects.filter(
|
categories = rego.Category.objects.filter(
|
||||||
discountforcategory__discount=self.ceiling
|
discountforcategory__discount=self.ceiling,
|
||||||
)
|
)
|
||||||
return rego.Product.objects.filter(
|
return rego.Product.objects.filter(
|
||||||
Q(discountforproduct__discount=self.ceiling) |
|
Q(discountforproduct__discount=self.ceiling) |
|
||||||
|
@ -129,7 +132,7 @@ class TimeOrStockLimitConditionController(ConditionController):
|
||||||
|
|
||||||
reserved_carts = rego.Cart.reserved_carts()
|
reserved_carts = rego.Cart.reserved_carts()
|
||||||
product_items = rego.ProductItem.objects.filter(
|
product_items = rego.ProductItem.objects.filter(
|
||||||
product=self._products().all()
|
product__in=self._products().all(),
|
||||||
)
|
)
|
||||||
product_items = product_items.filter(cart=reserved_carts)
|
product_items = product_items.filter(cart=reserved_carts)
|
||||||
|
|
||||||
|
@ -154,5 +157,6 @@ class VoucherConditionController(ConditionController):
|
||||||
''' returns True if the user has the given voucher attached. '''
|
''' returns True if the user has the given voucher attached. '''
|
||||||
carts = rego.Cart.objects.filter(
|
carts = rego.Cart.objects.filter(
|
||||||
user=user,
|
user=user,
|
||||||
vouchers=self.condition.voucher)
|
vouchers=self.condition.voucher,
|
||||||
|
)
|
||||||
return len(carts) > 0
|
return len(carts) > 0
|
||||||
|
|
|
@ -43,7 +43,7 @@ class ProductController(object):
|
||||||
|
|
||||||
carts = rego.Cart.objects.filter(user=user)
|
carts = rego.Cart.objects.filter(user=user)
|
||||||
items = rego.ProductItem.objects.filter(
|
items = rego.ProductItem.objects.filter(
|
||||||
cart=carts,
|
cart__in=carts,
|
||||||
)
|
)
|
||||||
|
|
||||||
prod_items = items.filter(product=self.product)
|
prod_items = items.filter(product=self.product)
|
||||||
|
@ -52,6 +52,11 @@ class ProductController(object):
|
||||||
prod_count = prod_items.aggregate(Sum("quantity"))["quantity__sum"]
|
prod_count = prod_items.aggregate(Sum("quantity"))["quantity__sum"]
|
||||||
cat_count = cat_items.aggregate(Sum("quantity"))["quantity__sum"]
|
cat_count = cat_items.aggregate(Sum("quantity"))["quantity__sum"]
|
||||||
|
|
||||||
|
if prod_count == None:
|
||||||
|
prod_count = 0
|
||||||
|
if cat_count == None:
|
||||||
|
cat_count = 0
|
||||||
|
|
||||||
prod_limit = self.product.limit_per_user
|
prod_limit = self.product.limit_per_user
|
||||||
prod_met = prod_limit is None or quantity + prod_count <= prod_limit
|
prod_met = prod_limit is None or quantity + prod_count <= prod_limit
|
||||||
|
|
||||||
|
|
Loading…
Reference in a new issue