Merge branch 'chrisjrn/20160913-bugs'
This commit is contained in:
		
						commit
						d5295e07a9
					
				
					 4 changed files with 22 additions and 9 deletions
				
			
		|  | @ -205,12 +205,12 @@ class CartController(object): | |||
|             to_add = sum(i[1] for i in by_cat[category]) | ||||
| 
 | ||||
|             if to_add > limit: | ||||
|                 errors.append(( | ||||
|                     category, | ||||
|                     "You may only have %d items in category: %s" % ( | ||||
|                 message_base = "You may only add %d items from category: %s" | ||||
|                 message = message_base % ( | ||||
|                     limit, category.name, | ||||
|                 ) | ||||
|                 )) | ||||
|                 for product, quantity in by_cat[category]: | ||||
|                     errors.append((product, message)) | ||||
| 
 | ||||
|         # Test the flag conditions | ||||
|         errs = FlagController.test_flags( | ||||
|  |  | |||
|  | @ -84,7 +84,7 @@ class ItemController(object): | |||
|                 aggregating like products from across multiple invoices. | ||||
| 
 | ||||
|         ''' | ||||
|         return self._items(commerce.Cart.STATUS_PAID) | ||||
|         return self._items(commerce.Cart.STATUS_PAID, category=category) | ||||
| 
 | ||||
|     def items_pending(self): | ||||
|         ''' Gets all of the items that the user has reserved, but has not yet | ||||
|  |  | |||
|  | @ -18,6 +18,10 @@ from reports import Report | |||
| from reports import report_view | ||||
| 
 | ||||
| 
 | ||||
| def CURRENCY(): | ||||
|     return models.DecimalField(decimal_places=2) | ||||
| 
 | ||||
| 
 | ||||
| @user_passes_test(views._staff_only) | ||||
| def reports_list(request): | ||||
|     ''' Lists all of the reports currently available. ''' | ||||
|  | @ -101,7 +105,9 @@ def reconciliation(request, form): | |||
|         invoice__status=commerce.Invoice.STATUS_PAID, | ||||
|     ).values( | ||||
|         "price", "quantity" | ||||
|     ).aggregate(total=Sum(F("price") * F("quantity"))) | ||||
|     ).aggregate( | ||||
|         total=Sum(F("price") * F("quantity"), output_field=CURRENCY()), | ||||
|     ) | ||||
| 
 | ||||
|     data.append(["Paid items", sales["total"]]) | ||||
| 
 | ||||
|  |  | |||
|  | @ -826,6 +826,10 @@ def amend_registration(request, user_id): | |||
|         prefix="products", | ||||
|     ) | ||||
| 
 | ||||
|     for item, form in zip(items, formset): | ||||
|         queryset = inventory.Product.objects.filter(id=item.product.id) | ||||
|         form.fields["product"].queryset = queryset | ||||
| 
 | ||||
|     voucher_form = forms.VoucherForm( | ||||
|         request.POST or None, | ||||
|         prefix="voucher", | ||||
|  | @ -847,10 +851,13 @@ def amend_registration(request, user_id): | |||
|             for ve_field in ve.error_list: | ||||
|                 product, message = ve_field.message | ||||
|                 for form in formset: | ||||
|                     if "product" not in form.cleaned_data: | ||||
|                         # This is the empty form. | ||||
|                         continue | ||||
|                     if form.cleaned_data["product"] == product: | ||||
|                         form.add_error("quantity", message) | ||||
| 
 | ||||
|     if request.POST and voucher_form.is_valid(): | ||||
|     if request.POST and voucher_form.has_changed() and voucher_form.is_valid(): | ||||
|         try: | ||||
|             current_cart.apply_voucher(voucher_form.cleaned_data["voucher"]) | ||||
|             return redirect(amend_registration, user_id) | ||||
|  |  | |||
		Loading…
	
	Add table
		
		Reference in a new issue
	
	 Christopher Neugebauer
						Christopher Neugebauer