diff --git a/tailbone/grids/search.py b/tailbone/grids/search.py index 95341207..c3051f31 100644 --- a/tailbone/grids/search.py +++ b/tailbone/grids/search.py @@ -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 . # ################################################################################ - """ 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)