Fix qhasuery modification so that conditions are combined
Borrowed from the pyconau-2017 fork To explain the impact of this - without this patch, if a user has their invoice refunded, they are able to buy a new ticket; but t-shirts, dinner tickets and so on do not become available to them again because they are listed has already been in a cart for them. Applying the patch now correctly checks to see if they currently have a ticket. From 731eee0a4c42a5013ee312b1ff50548e4d89a2ff Mon Sep 17 00:00:00 2001 From: Richard Jones <r1chardj0n3s@gmail.com> Date: Sun, 4 Jun 2017 13:22:34 +1000 Subject: [PATCH] Fix query modification so that conditions are combined Previously it was checking if the user has a product from the category in a cart, and if there is no cart that is released (refunded). Not *if the user has a product in a cart that is not released*. This patch combines them. In the absence of a __ne operation in the joining syntax, a double equality check is needed. Signed-off-by: Richard Jones <r1chardj0n3s@gmail.com>
This commit is contained in:
		
							parent
							
								
									105e6988e5
								
							
						
					
					
						commit
						e546b7d814
					
				
					 1 changed files with 7 additions and 7 deletions
				
			
		|  | @ -152,16 +152,16 @@ class CategoryConditionController(IsMetByFilter, ConditionController): | ||||||
|         product from a category invoking that item's condition in one of their |         product from a category invoking that item's condition in one of their | ||||||
|         carts. ''' |         carts. ''' | ||||||
| 
 | 
 | ||||||
|  |         active = commerce.Cart.STATUS_ACTIVE | ||||||
|  |         paid = commerce.Cart.STATUS_PAID | ||||||
|         in_user_carts = Q( |         in_user_carts = Q( | ||||||
|             enabling_category__product__productitem__cart__user=user |             enabling_category__product__productitem__cart__user=user, | ||||||
|         ) |             enabling_category__product__productitem__cart__status=active | ||||||
|         released = commerce.Cart.STATUS_RELEASED |         ) | Q( | ||||||
|         in_released_carts = Q( |             enabling_category__product__productitem__cart__user=user, | ||||||
|             enabling_category__product__productitem__cart__status=released |             enabling_category__product__productitem__cart__status=paid | ||||||
|         ) |         ) | ||||||
|         queryset = queryset.filter(in_user_carts) |         queryset = queryset.filter(in_user_carts) | ||||||
|         queryset = queryset.exclude(in_released_carts) |  | ||||||
| 
 |  | ||||||
|         return queryset |         return queryset | ||||||
| 
 | 
 | ||||||
| 
 | 
 | ||||||
|  |  | ||||||
		Loading…
	
	Add table
		
		Reference in a new issue
	
	 James Polley
						James Polley