Part of CartController->BatchController memoisation
This commit is contained in:
		
							parent
							
								
									efb73e7a68
								
							
						
					
					
						commit
						3ab5ac32ca
					
				
					 1 changed files with 25 additions and 23 deletions
				
			
		|  | @ -5,9 +5,10 @@ from registrasion import util | ||||||
| from registrasion.models import commerce | from registrasion.models import commerce | ||||||
| from registrasion.models import inventory | from registrasion.models import inventory | ||||||
| from registrasion.models import people | 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.cart import CartController | ||||||
| from registrasion.controllers.credit_note import CreditNoteController | from registrasion.controllers.credit_note import CreditNoteController | ||||||
|  | from registrasion.controllers.discount import DiscountController | ||||||
| from registrasion.controllers.invoice import InvoiceController | from registrasion.controllers.invoice import InvoiceController | ||||||
| from registrasion.controllers.product import ProductController | from registrasion.controllers.product import ProductController | ||||||
| from registrasion.exceptions import CartValidationError | from registrasion.exceptions import CartValidationError | ||||||
|  | @ -170,18 +171,18 @@ def guided_registration(request): | ||||||
|             category__in=cats, |             category__in=cats, | ||||||
|         ).select_related("category") |         ).select_related("category") | ||||||
| 
 | 
 | ||||||
|         available_products = set(ProductController.available_products( |         with BatchController.batch(request.user): | ||||||
|             request.user, |             available_products = set(ProductController.available_products( | ||||||
|             products=all_products, |                 request.user, | ||||||
|         )) |                 products=all_products, | ||||||
|  |             )) | ||||||
| 
 | 
 | ||||||
|         if len(available_products) == 0: |             if len(available_products) == 0: | ||||||
|             # We've filled in every category |                 # We've filled in every category | ||||||
|             attendee.completed_registration = True |                 attendee.completed_registration = True | ||||||
|             attendee.save() |                 attendee.save() | ||||||
|             return next_step |                 return next_step | ||||||
| 
 | 
 | ||||||
|         with CartController.operations_batch(request.user): |  | ||||||
|             for category in cats: |             for category in cats: | ||||||
|                 products = [ |                 products = [ | ||||||
|                     i for i in available_products |                     i for i in available_products | ||||||
|  | @ -345,20 +346,21 @@ def product_category(request, category_id): | ||||||
|     category_id = int(category_id)  # Routing is [0-9]+ |     category_id = int(category_id)  # Routing is [0-9]+ | ||||||
|     category = inventory.Category.objects.get(pk=category_id) |     category = inventory.Category.objects.get(pk=category_id) | ||||||
| 
 | 
 | ||||||
|     products = ProductController.available_products( |     with BatchController.batch(request.user): | ||||||
|         request.user, |         products = ProductController.available_products( | ||||||
|         category=category, |             request.user, | ||||||
|     ) |             category=category, | ||||||
| 
 |  | ||||||
|     if not products: |  | ||||||
|         messages.warning( |  | ||||||
|             request, |  | ||||||
|             "There are no products available from category: " + category.name, |  | ||||||
|         ) |         ) | ||||||
|         return redirect("dashboard") |  | ||||||
| 
 | 
 | ||||||
|     p = _handle_products(request, category, products, PRODUCTS_FORM_PREFIX) |         if not products: | ||||||
|     products_form, discounts, products_handled = p |             messages.warning( | ||||||
|  |                 request, | ||||||
|  |                 "There are no products available from category: " + category.name, | ||||||
|  |             ) | ||||||
|  |             return redirect("dashboard") | ||||||
|  | 
 | ||||||
|  |         p = _handle_products(request, category, products, PRODUCTS_FORM_PREFIX) | ||||||
|  |         products_form, discounts, products_handled = p | ||||||
| 
 | 
 | ||||||
|     if request.POST and not voucher_handled and not products_form.errors: |     if request.POST and not voucher_handled and not products_form.errors: | ||||||
|         # Only return to the dashboard if we didn't add a voucher code |         # Only return to the dashboard if we didn't add a voucher code | ||||||
|  |  | ||||||
		Loading…
	
	Add table
		
		Reference in a new issue
	
	 Christopher Neugebauer
						Christopher Neugebauer