Wraps the guided registration handler in views.py in a batch marker
This commit is contained in:
parent
587e6e20b2
commit
76e6206d09
1 changed files with 25 additions and 23 deletions
|
@ -181,33 +181,35 @@ def guided_registration(request):
|
||||||
attendee.save()
|
attendee.save()
|
||||||
return next_step
|
return next_step
|
||||||
|
|
||||||
for category in cats:
|
with CartController.operations_batch(request.user):
|
||||||
products = [
|
for category in cats:
|
||||||
i for i in available_products
|
products = [
|
||||||
if i.category == category
|
i for i in available_products
|
||||||
]
|
if i.category == category
|
||||||
|
]
|
||||||
|
|
||||||
prefix = "category_" + str(category.id)
|
prefix = "category_" + str(category.id)
|
||||||
p = _handle_products(request, category, products, prefix)
|
p = _handle_products(request, category, products, prefix)
|
||||||
products_form, discounts, products_handled = p
|
products_form, discounts, products_handled = p
|
||||||
|
|
||||||
section = GuidedRegistrationSection(
|
section = GuidedRegistrationSection(
|
||||||
title=category.name,
|
title=category.name,
|
||||||
description=category.description,
|
description=category.description,
|
||||||
discounts=discounts,
|
discounts=discounts,
|
||||||
form=products_form,
|
form=products_form,
|
||||||
)
|
)
|
||||||
|
|
||||||
if products:
|
if products:
|
||||||
# This product category has items to show.
|
# This product category has items to show.
|
||||||
sections.append(section)
|
sections.append(section)
|
||||||
# Add this to the list of things to show if the form errors.
|
# Add this to the list of things to show if the form
|
||||||
request.session[SESSION_KEY].append(category.id)
|
# errors.
|
||||||
|
request.session[SESSION_KEY].append(category.id)
|
||||||
|
|
||||||
if request.method == "POST" and not products_form.errors:
|
if request.method == "POST" and not products_form.errors:
|
||||||
# This is only saved if we pass each form with no errors,
|
# This is only saved if we pass each form with no
|
||||||
# and if the form actually has products.
|
# errors, and if the form actually has products.
|
||||||
attendee.guided_categories_complete.add(category)
|
attendee.guided_categories_complete.add(category)
|
||||||
|
|
||||||
if sections and request.method == "POST":
|
if sections and request.method == "POST":
|
||||||
for section in sections:
|
for section in sections:
|
||||||
|
|
Loading…
Reference in a new issue