diff options
Diffstat (limited to 'ishtar_common')
-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 |