diff options
author | Étienne Loks <etienne.loks@iggdrasil.net> | 2019-06-18 13:18:15 +0200 |
---|---|---|
committer | Étienne Loks <etienne.loks@iggdrasil.net> | 2019-06-18 13:18:15 +0200 |
commit | 7e88cdb11d1fa38088304ba7572c7a614856bce1 (patch) | |
tree | 191bb3c023094df3758d66e10525056db6fffc13 /ishtar_common/views_item.py | |
parent | f1e6493674b29a7c9f13e40c3b12d5473853613a (diff) | |
download | Ishtar-7e88cdb11d1fa38088304ba7572c7a614856bce1.tar.bz2 Ishtar-7e88cdb11d1fa38088304ba7572c7a614856bce1.zip |
Free search: manage by default with startswith
Diffstat (limited to 'ishtar_common/views_item.py')
-rw-r--r-- | ishtar_common/views_item.py | 20 |
1 files changed, 11 insertions, 9 deletions
diff --git a/ishtar_common/views_item.py b/ishtar_common/views_item.py index 53c65c3aa..93ab133a0 100644 --- a/ishtar_common/views_item.py +++ b/ishtar_common/views_item.py @@ -499,15 +499,17 @@ def _parse_query_string(string, query_parameters, current_dct, exc_dct, if len(string) != 1: for reserved_char in RESERVED_CHAR: string = string.replace(reserved_char, u"") - # like search if string.endswith(u'*'): if len(string.strip()) == 1: return u"" - string = string[:-1] + u':*' - if string.startswith(u'-'): + string = string[:-1] + ':*' + elif string not in ("&", "|", "!", "-"): + # like search by default + string = string + ':*' + if string.startswith('-'): if len(string.strip()) == 1: - return u"" - string = u"!" + string[1:] + return "" + string = "!" + string[1:] return string @@ -874,9 +876,9 @@ def _manage_hierarchic_fields(dct, and_reqs): if val.endswith(u'"') and val.startswith(u'"'): val = val[1:-1] # manage search text by label - if u"*" in val: + if "*" in val: suffix = "label__icontains" - val = val.replace(u'*', u"") + val = val.replace('*', u"") else: suffix = "label__iexact" req = req[:-(len(base_suffix))] + suffix @@ -902,9 +904,9 @@ def _manage_clean_search_field(dct): dct[k] = _clean_type_val(dct[k]) if '*' in dct[k] and k.endswith('__iexact'): value = dct.pop(k).strip() - if value.startswith(u"*"): + if value.startswith("*"): value = value[1:] - if value.endswith(u"*"): + if value.endswith("*"): value = value[:-1] dct[k[:-len('__iexact')] + '__icontains'] = value |