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
|
@ -2,7 +2,7 @@
|
|||
################################################################################
|
||||
#
|
||||
# Rattail -- Retail Software Framework
|
||||
# Copyright © 2010-2014 Lance Edgar
|
||||
# Copyright © 2010-2015 Lance Edgar
|
||||
#
|
||||
# This file is part of Rattail.
|
||||
#
|
||||
|
@ -20,11 +20,12 @@
|
|||
# along with Rattail. If not, see <http://www.gnu.org/licenses/>.
|
||||
#
|
||||
################################################################################
|
||||
|
||||
"""
|
||||
Grid Search Filters
|
||||
"""
|
||||
|
||||
from __future__ import unicode_literals
|
||||
|
||||
from sqlalchemy import func, or_
|
||||
|
||||
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):
|
||||
"""
|
||||
Filters ``query`` according to ``config`` and ``filter_map``. ``join_map``
|
||||
is used, if necessary, to join additional tables to the base query. The
|
||||
Filters the given query according to filter and sorting hints found within
|
||||
the config dictionary, using the filter and join maps as needed. The
|
||||
filtered query is returned.
|
||||
"""
|
||||
|
||||
joins = config.setdefault('joins', [])
|
||||
for key in config:
|
||||
if key.startswith('include_filter_') and config[key]:
|
||||
field = key[15:]
|
||||
value = config.get(field)
|
||||
if value:
|
||||
if value != '':
|
||||
if field in join_map and field not in joins:
|
||||
query = join_map[field](query)
|
||||
joins.append(field)
|
||||
|
|
Loading…
Reference in a new issue