Alter guided_registrasion logic to handle new page

This is required for the new method of accepting terms and conditions
This commit is contained in:
James Polley 2017-10-01 22:54:04 +11:00
parent b8dcbd89b7
commit 362ed28be2
2 changed files with 29 additions and 9 deletions

View file

@ -262,8 +262,12 @@ class _CheckboxProductsForm(_ProductsForm):
@classmethod
def set_fields(cls, category, products):
for product in products:
if product.price:
label='%s -- $%s' % (product.name, product.price)
else:
label='%s' % (product.name)
field = forms.BooleanField(
label='%s -- $%s' % (product.name, product.price),
label=label,
required=False,
)
cls.base_fields[cls.field_name(product)] = field

View file

@ -1,6 +1,9 @@
import datetime
import zipfile
import os
import logging
from django.contrib import messages
from . import forms
from . import util
@ -43,7 +46,6 @@ from registrasion.contrib.badger import (
InvalidTicketChoiceError
)
_GuidedRegistrationSection = namedtuple(
"GuidedRegistrationSection",
(
@ -107,9 +109,10 @@ def guided_registration(request, page_number=None):
PAGE_PROFILE = 1
PAGE_TICKET = 2
PAGE_PRODUCTS = 3
PAGE_PRODUCTS_MAX = 4
TOTAL_PAGES = 4
PAGE_TERMS = 3
PAGE_PRODUCTS = 4
PAGE_PRODUCTS_MAX = 5
TOTAL_PAGES = 5
ticket_category = inventory.Category.objects.get(
id=settings.TICKET_PRODUCT_CATEGORY
@ -136,12 +139,18 @@ def guided_registration(request, page_number=None):
products = inventory.Product.objects.filter(
productitem__cart=cart.cart
)
products = products.filter(category=ticket_category)
tickets = products.filter(category=ticket_category)
if products.count() == 0:
logger.debug("tickets count %s" % tickets.count())
logger.debug("products: %s" % products.count())
if tickets.count() == 0:
# If no ticket, they can only see the profile or ticket page.
max_page = PAGE_TICKET
redirect_page = PAGE_TICKET
elif products.count() == 1:
# They have a ticket, now to accept terms and conditions
max_page = PAGE_TERMS
redirect_page = PAGE_TERMS
else:
# If there's a ticket, they should *see* the general products page#
# but be able to go to the overflow page if needs be.
@ -180,6 +189,12 @@ def guided_registration(request, page_number=None):
sections = _guided_registration_products(
request, GUIDED_MODE_TICKETS_ONLY
)
elif page_number == PAGE_TERMS:
# Accept terms
title = "Terms and Conditions"
sections = _guided_registration_products(
request, GUIDED_MODE_TERMS
)
elif page_number == PAGE_PRODUCTS:
# Select additional items
title = "Additional items"
@ -219,8 +234,9 @@ def guided_registration(request, page_number=None):
GUIDED_MODE_TICKETS_ONLY = 2
GUIDED_MODE_ALL_ADDITIONAL = 3
GUIDED_MODE_EXCLUDE_COMPLETE = 4
GUIDED_MODE_TERMS = 3
GUIDED_MODE_ALL_ADDITIONAL = 4
GUIDED_MODE_EXCLUDE_COMPLETE =5
@login_required