From 6c9a68dc5b2a3e4d874f4eb73bf198b8f8115dd7 Mon Sep 17 00:00:00 2001
From: Christopher Neugebauer <chrisjrn@gmail.com>
Date: Sat, 2 Apr 2016 20:11:40 +1100
Subject: [PATCH] Fixes #8 properly

---
 registrasion/views.py | 12 ++++--------
 1 file changed, 4 insertions(+), 8 deletions(-)

diff --git a/registrasion/views.py b/registrasion/views.py
index 3efdc0ad..f7e87694 100644
--- a/registrasion/views.py
+++ b/registrasion/views.py
@@ -121,10 +121,6 @@ def guided_registration(request, page_id=0):
                 category=category,
             )
 
-            if not products:
-                # This product category does not exist for this user
-                continue
-
             prefix = "category_" + str(category.id)
             p = handle_products(request, category, products, prefix)
             products_form, discounts, products_handled = p
@@ -135,7 +131,9 @@ def guided_registration(request, page_id=0):
                 discounts=discounts,
                 form=products_form,
             )
-            sections.append(section)
+            if products:
+                # This product category does not exist for this user
+                sections.append(section)
 
             if request.method == "POST" and not products_form.errors:
                 if category.id > attendee.highest_complete_category:
@@ -323,10 +321,8 @@ def handle_products(request, category, products, prefix):
 
 
 def set_quantities_from_products_form(products_form, current_cart):
-    # TODO: issue #8 is a problem here.
-    quantities = list(products_form.product_quantities())
-    quantities.sort(key=lambda item: item[1])
 
+    quantities = products_form.product_quantities()
     product_quantities = [
         (rego.Product.objects.get(pk=i[0]), i[1]) for i in quantities
     ]