Fix bug with default search filters for SA grids.
Sometimes the default search value needs to be `False`, in which case we do want the filter to fire.
This commit is contained in:
		
							parent
							
								
									cf7f884f80
								
							
						
					
					
						commit
						107da5dd9d
					
				
					 1 changed files with 6 additions and 6 deletions
				
			
		| 
						 | 
					@ -2,7 +2,7 @@
 | 
				
			||||||
################################################################################
 | 
					################################################################################
 | 
				
			||||||
#
 | 
					#
 | 
				
			||||||
#  Rattail -- Retail Software Framework
 | 
					#  Rattail -- Retail Software Framework
 | 
				
			||||||
#  Copyright © 2010-2014 Lance Edgar
 | 
					#  Copyright © 2010-2015 Lance Edgar
 | 
				
			||||||
#
 | 
					#
 | 
				
			||||||
#  This file is part of Rattail.
 | 
					#  This file is part of Rattail.
 | 
				
			||||||
#
 | 
					#
 | 
				
			||||||
| 
						 | 
					@ -20,11 +20,12 @@
 | 
				
			||||||
#  along with Rattail.  If not, see <http://www.gnu.org/licenses/>.
 | 
					#  along with Rattail.  If not, see <http://www.gnu.org/licenses/>.
 | 
				
			||||||
#
 | 
					#
 | 
				
			||||||
################################################################################
 | 
					################################################################################
 | 
				
			||||||
 | 
					 | 
				
			||||||
"""
 | 
					"""
 | 
				
			||||||
Grid Search Filters
 | 
					Grid Search Filters
 | 
				
			||||||
"""
 | 
					"""
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					from __future__ import unicode_literals
 | 
				
			||||||
 | 
					
 | 
				
			||||||
from sqlalchemy import func, or_
 | 
					from sqlalchemy import func, or_
 | 
				
			||||||
 | 
					
 | 
				
			||||||
from webhelpers.html import tags
 | 
					from webhelpers.html import tags
 | 
				
			||||||
| 
						 | 
					@ -294,17 +295,16 @@ def get_search_form(request, filter_map, config):
 | 
				
			||||||
 | 
					
 | 
				
			||||||
def filter_query(query, config, filter_map, join_map):
 | 
					def filter_query(query, config, filter_map, join_map):
 | 
				
			||||||
    """
 | 
					    """
 | 
				
			||||||
    Filters ``query`` according to ``config`` and ``filter_map``.  ``join_map``
 | 
					    Filters the given query according to filter and sorting hints found within
 | 
				
			||||||
    is used, if necessary, to join additional tables to the base query.  The
 | 
					    the config dictionary, using the filter and join maps as needed.  The
 | 
				
			||||||
    filtered query is returned.
 | 
					    filtered query is returned.
 | 
				
			||||||
    """
 | 
					    """
 | 
				
			||||||
 | 
					 | 
				
			||||||
    joins = config.setdefault('joins', [])
 | 
					    joins = config.setdefault('joins', [])
 | 
				
			||||||
    for key in config:
 | 
					    for key in config:
 | 
				
			||||||
        if key.startswith('include_filter_') and config[key]:
 | 
					        if key.startswith('include_filter_') and config[key]:
 | 
				
			||||||
            field = key[15:]
 | 
					            field = key[15:]
 | 
				
			||||||
            value = config.get(field)
 | 
					            value = config.get(field)
 | 
				
			||||||
            if value:
 | 
					            if value != '':
 | 
				
			||||||
                if field in join_map and field not in joins:
 | 
					                if field in join_map and field not in joins:
 | 
				
			||||||
                    query = join_map[field](query)
 | 
					                    query = join_map[field](query)
 | 
				
			||||||
                    joins.append(field)
 | 
					                    joins.append(field)
 | 
				
			||||||
| 
						 | 
					
 | 
				
			||||||
		Loading…
	
	Add table
		Add a link
		
	
		Reference in a new issue