diff options
author | Étienne Loks <etienne.loks@iggdrasil.net> | 2018-11-08 11:32:34 +0100 |
---|---|---|
committer | Étienne Loks <etienne.loks@iggdrasil.net> | 2018-11-08 11:32:34 +0100 |
commit | 43ce28e0926e991a0b7e34e11cb943e640ae12b5 (patch) | |
tree | efe7dd2baf8c357eb7d7f9ee9d34345e08b506e2 /ishtar_common/views_item.py | |
parent | 83f352f37c8f034ebeca188a9716aafec765dfdf (diff) | |
download | Ishtar-43ce28e0926e991a0b7e34e11cb943e640ae12b5.tar.bz2 Ishtar-43ce28e0926e991a0b7e34e11cb943e640ae12b5.zip |
Search: manage criteria + text search
Diffstat (limited to 'ishtar_common/views_item.py')
-rw-r--r-- | ishtar_common/views_item.py | 19 |
1 files changed, 12 insertions, 7 deletions
diff --git a/ishtar_common/views_item.py b/ishtar_common/views_item.py index 7c6cbc24a..c14973bc3 100644 --- a/ishtar_common/views_item.py +++ b/ishtar_common/views_item.py @@ -391,7 +391,7 @@ def _parse_parentheses_groups(groups, request_keys, current_dct=None, SEP = u"?ç;?" # replace spaces inside quote with this characters previous_quote = None while found != -1: - if previous_quote: + if previous_quote is not None: string = string[0:previous_quote] + \ string[previous_quote:found].replace(u' ', SEP) + \ string[found:] @@ -448,17 +448,22 @@ def _search_manage_search_vector(model, dct, exc_dct, request_keys): search_query, extra_dct, extra_exc_dct = _parse_parentheses_groups( parentheses_groups, request_keys) dct.update(extra_dct) + exc_dct.update(extra_exc_dct) if search_query: # remove inside parenthesis search_query = \ search_query.replace(u'(', u'').replace(u')', u'').strip() - dct['extras'].append( - {'where': [model._meta.db_table + - ".search_vector @@ (to_tsquery(%s, %s)) = true"], - 'params': [settings.ISHTAR_SEARCH_LANGUAGE, - search_query]} - ) + # manage full quoted + if search_query.startswith(u'"') and search_query.endswith(u'"'): + search_query = search_query[1:-1].replace(u" ", u" & ").strip() + if search_query: + dct['extras'].append( + {'where': [model._meta.db_table + + ".search_vector @@ (to_tsquery(%s, %s)) = true"], + 'params': [settings.ISHTAR_SEARCH_LANGUAGE, + search_query]} + ) return dct, exc_dct |