Changeset - 3ab5ac32cadc
[Not reviewed]
0 1 0
Christopher Neugebauer - 8 years ago 2016-05-01 04:56:51
chrisjrn@gmail.com
Part of CartController->BatchController memoisation
1 file changed with 4 insertions and 2 deletions:
0 comments (0 inline, 0 general)
registrasion/views.py
Show inline comments
...
 
@@ -2,15 +2,16 @@ import sys
 

	
 
from registrasion import forms
 
from registrasion import util
 
from registrasion.models import commerce
 
from registrasion.models import inventory
 
from registrasion.models import people
 
from registrasion.controllers.discount import DiscountController
 
from registrasion.controllers.batch import BatchController
 
from registrasion.controllers.cart import CartController
 
from registrasion.controllers.credit_note import CreditNoteController
 
from registrasion.controllers.discount import DiscountController
 
from registrasion.controllers.invoice import InvoiceController
 
from registrasion.controllers.product import ProductController
 
from registrasion.exceptions import CartValidationError
 

	
 
from collections import namedtuple
 

	
...
 
@@ -167,24 +168,24 @@ def guided_registration(request):
 
            title = "Additional items"
 

	
 
        all_products = inventory.Product.objects.filter(
 
            category__in=cats,
 
        ).select_related("category")
 

	
 
        with BatchController.batch(request.user):
 
            available_products = set(ProductController.available_products(
 
                request.user,
 
                products=all_products,
 
            ))
 

	
 
            if len(available_products) == 0:
 
                # We've filled in every category
 
                attendee.completed_registration = True
 
                attendee.save()
 
                return next_step
 

	
 
        with CartController.operations_batch(request.user):
 
            for category in cats:
 
                products = [
 
                    i for i in available_products
 
                    if i.category == category
 
                ]
 

	
...
 
@@ -342,12 +343,13 @@ def product_category(request, category_id):
 
    v = _handle_voucher(request, VOUCHERS_FORM_PREFIX)
 
    voucher_form, voucher_handled = v
 

	
 
    category_id = int(category_id)  # Routing is [0-9]+
 
    category = inventory.Category.objects.get(pk=category_id)
 

	
 
    with BatchController.batch(request.user):
 
        products = ProductController.available_products(
 
            request.user,
 
            category=category,
 
        )
 

	
 
        if not products:
0 comments (0 inline, 0 general)