diff options
author | Alexandru DAMIAN <alexandru.damian@intel.com> | 2014-04-08 16:10:33 +0000 |
---|---|---|
committer | Richard Purdie <richard.purdie@linuxfoundation.org> | 2014-04-09 16:59:04 +0100 |
commit | 845b081fc108c656f04d4a70afa4695defc13c9f (patch) | |
tree | 865350be5a2d38d0f673f55b8600198f30fcd064 /lib/toaster/toastergui/views.py | |
parent | a84f296591be26972b808e98816e9d92cadf3eb5 (diff) | |
download | bitbake-845b081fc108c656f04d4a70afa4695defc13c9f.tar.gz |
toaster: fix filtering query for multiple filters
This is a fix for using multiple expressions in filters.
Three different issues are touched:
* added an explicit error message for incorrect filter usage
* changed the value separator to something that will pass
through from the browser to the actual code
* changed the "and" operator for combining Q from a dubios
lambda function to the standard operator.and_
Signed-off-by: Alexandru DAMIAN <alexandru.damian@intel.com>
Signed-off-by: Richard Purdie <richard.purdie@linuxfoundation.org>
Diffstat (limited to 'lib/toaster/toastergui/views.py')
-rw-r--r-- | lib/toaster/toastergui/views.py | 6 |
1 files changed, 3 insertions, 3 deletions
diff --git a/lib/toaster/toastergui/views.py b/lib/toaster/toastergui/views.py index 96ce4d7fc..4ed99400c 100644 --- a/lib/toaster/toastergui/views.py +++ b/lib/toaster/toastergui/views.py @@ -80,7 +80,7 @@ def _redirect_parameters(view, g, mandatory_parameters, *args, **kwargs): return redirect(url + "?%s" % urllib.urlencode(params), *args, **kwargs) FIELD_SEPARATOR = ":" -VALUE_SEPARATOR = ";" +VALUE_SEPARATOR = "!" DESCENDING = "-" def __get_q_for_val(name, value): @@ -102,7 +102,7 @@ def _get_filtering_query(filter_string): values = search_terms[1].split(VALUE_SEPARATOR) querydict = dict(zip(keys, values)) - return reduce(lambda x, y: x & y, map(lambda x: __get_q_for_val(k, querydict[k]),[k for k in querydict])) + return reduce(operator.and_, map(lambda x: __get_q_for_val(x, querydict[x]), [k for k in querydict])) def _get_toggle_order(request, orderkey, reverse = False): if reverse: @@ -128,7 +128,7 @@ def _validate_input(input, model): # Check we have only one colon if len(input_list) != 2: - invalid = "We have an invalid number of separators" + invalid = "We have an invalid number of separators: " + input + " -> " + str(input_list) return None, invalid # Check we have an equal number of terms both sides of the colon |