From 68e7e4e594fbfb862bf3da63d714ed0fde2c6a45 Mon Sep 17 00:00:00 2001 From: Christopher Neugebauer Date: Fri, 4 Mar 2016 14:35:09 -0800 Subject: [PATCH] Checks enabling conditions before adding items to the list --- registrasion/views.py | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/registrasion/views.py b/registrasion/views.py index 4e5f372a..d13028ac 100644 --- a/registrasion/views.py +++ b/registrasion/views.py @@ -2,6 +2,7 @@ from registrasion import forms from registrasion import models as rego from registrasion.controllers.cart import CartController from registrasion.controllers.invoice import InvoiceController +from registrasion.controllers.product import ProductController from django.contrib.auth.decorators import login_required from django.core.exceptions import ObjectDoesNotExist @@ -42,6 +43,11 @@ def product_category(request, category_id): items = rego.ProductItem.objects.filter(product__category=category) products = products.order_by("order") for product in products: + # Only add items that are enabled. + prod = ProductController(product) + if not prod.can_add_with_enabling_conditions(request.user, 0): + continue + try: quantity = items.get(product=product).quantity except ObjectDoesNotExist: