_filtered_flags now no longer cares about products for filtering. It just does everything.
This commit is contained in:
		
							parent
							
								
									c6fdfa496e
								
							
						
					
					
						commit
						b3491cab8e
					
				
					 1 changed files with 3 additions and 14 deletions
				
			
		|  | @ -47,8 +47,6 @@ class FlagController(object): | ||||||
|         a list is returned containing all of the products that are *not |         a list is returned containing all of the products that are *not | ||||||
|         enabled*. ''' |         enabled*. ''' | ||||||
| 
 | 
 | ||||||
|         print "GREPME: test_flags()" |  | ||||||
| 
 |  | ||||||
|         if products is not None and product_quantities is not None: |         if products is not None and product_quantities is not None: | ||||||
|             raise ValueError("Please specify only products or " |             raise ValueError("Please specify only products or " | ||||||
|                              "product_quantities") |                              "product_quantities") | ||||||
|  | @ -62,7 +60,7 @@ class FlagController(object): | ||||||
| 
 | 
 | ||||||
|         if products: |         if products: | ||||||
|             # Simplify the query. |             # Simplify the query. | ||||||
|             all_conditions = cls._filtered_flags(user, products) |             all_conditions = cls._filtered_flags(user) | ||||||
|         else: |         else: | ||||||
|             all_conditions = [] |             all_conditions = [] | ||||||
| 
 | 
 | ||||||
|  | @ -160,7 +158,7 @@ class FlagController(object): | ||||||
|         return error_fields |         return error_fields | ||||||
| 
 | 
 | ||||||
|     @classmethod |     @classmethod | ||||||
|     def _filtered_flags(cls, user, products): |     def _filtered_flags(cls, user): | ||||||
|         ''' |         ''' | ||||||
| 
 | 
 | ||||||
|         Returns: |         Returns: | ||||||
|  | @ -171,16 +169,7 @@ class FlagController(object): | ||||||
|         types = list(ConditionController._controllers()) |         types = list(ConditionController._controllers()) | ||||||
|         flagtypes = [i for i in types if issubclass(i, conditions.FlagBase)] |         flagtypes = [i for i in types if issubclass(i, conditions.FlagBase)] | ||||||
| 
 | 
 | ||||||
|         # Get all flags for the products and categories. |         all_flags = conditions.FlagBase.objects.all() | ||||||
|         prods = ( |  | ||||||
|             product.flagbase_set.all() |  | ||||||
|             for product in products |  | ||||||
|         ) |  | ||||||
|         cats = ( |  | ||||||
|             category.flagbase_set.all() |  | ||||||
|             for category in set(product.category for product in products) |  | ||||||
|         ) |  | ||||||
|         all_flags = reduce(operator.or_, itertools.chain(prods, cats)) |  | ||||||
| 
 | 
 | ||||||
|         all_subsets = [] |         all_subsets = [] | ||||||
| 
 | 
 | ||||||
|  |  | ||||||
		Loading…
	
	Add table
		
		Reference in a new issue
	
	 Christopher Neugebauer
						Christopher Neugebauer