Fills in quantity boxes from the quantities in the current cart, not overall

This commit is contained in:
Christopher Neugebauer 2016-03-23 14:50:52 +11:00
parent 2d6b28c5a6
commit 4dc150d734

View file

@ -21,6 +21,7 @@ def product_category(request, category_id):
category_id = int(category_id) # Routing is [0-9]+ category_id = int(category_id) # Routing is [0-9]+
category = rego.Category.objects.get(pk=category_id) category = rego.Category.objects.get(pk=category_id)
current_cart = CartController.for_user(request.user)
CategoryForm = forms.CategoryForm(category) CategoryForm = forms.CategoryForm(category)
@ -30,7 +31,6 @@ def product_category(request, category_id):
if request.method == "POST": if request.method == "POST":
cat_form = CategoryForm(request.POST, request.FILES, prefix=PRODUCTS_FORM_PREFIX) cat_form = CategoryForm(request.POST, request.FILES, prefix=PRODUCTS_FORM_PREFIX)
voucher_form = forms.VoucherForm(request.POST, prefix=VOUCHERS_FORM_PREFIX) voucher_form = forms.VoucherForm(request.POST, prefix=VOUCHERS_FORM_PREFIX)
current_cart = CartController.for_user(request.user)
if voucher_form.is_valid(): if voucher_form.is_valid():
# Apply voucher # Apply voucher
@ -59,7 +59,10 @@ def product_category(request, category_id):
else: else:
# Create initial data for each of products in category # Create initial data for each of products in category
items = rego.ProductItem.objects.filter(product__category=category) items = rego.ProductItem.objects.filter(
product__category=category,
cart=current_cart.cart,
)
quantities = [] quantities = []
for product in products: for product in products:
# Only add items that are enabled. # Only add items that are enabled.