Checks enabling conditions before adding items to the list

This commit is contained in:
Christopher Neugebauer 2016-03-04 14:35:09 -08:00
parent 8400da17da
commit 68e7e4e594

View file

@ -2,6 +2,7 @@ from registrasion import forms
from registrasion import models as rego from registrasion import models as rego
from registrasion.controllers.cart import CartController from registrasion.controllers.cart import CartController
from registrasion.controllers.invoice import InvoiceController from registrasion.controllers.invoice import InvoiceController
from registrasion.controllers.product import ProductController
from django.contrib.auth.decorators import login_required from django.contrib.auth.decorators import login_required
from django.core.exceptions import ObjectDoesNotExist from django.core.exceptions import ObjectDoesNotExist
@ -42,6 +43,11 @@ def product_category(request, category_id):
items = rego.ProductItem.objects.filter(product__category=category) items = rego.ProductItem.objects.filter(product__category=category)
products = products.order_by("order") products = products.order_by("order")
for product in products: 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: try:
quantity = items.get(product=product).quantity quantity = items.get(product=product).quantity
except ObjectDoesNotExist: except ObjectDoesNotExist: