diff options
author | Étienne Loks <etienne.loks@iggdrasil.net> | 2018-07-04 17:50:10 +0200 |
---|---|---|
committer | Étienne Loks <etienne.loks@iggdrasil.net> | 2018-08-13 18:26:03 +0200 |
commit | f642961947a1a4fb79e49ff764d93b3f0ab474db (patch) | |
tree | 79b25c8593b8bdec8c938e12da00b1da9f57bba4 /ishtar_common | |
parent | aac03c20b75d0d12b63d532766b55714866d103e (diff) | |
download | Ishtar-f642961947a1a4fb79e49ff764d93b3f0ab474db.tar.bz2 Ishtar-f642961947a1a4fb79e49ff764d93b3f0ab474db.zip |
Criteria search: manage boolean search (refs #4180)
Diffstat (limited to 'ishtar_common')
-rw-r--r-- | ishtar_common/utils.py | 3 | ||||
-rw-r--r-- | ishtar_common/views_item.py | 11 |
2 files changed, 11 insertions, 3 deletions
diff --git a/ishtar_common/utils.py b/ishtar_common/utils.py index 189e91b8c..34d170892 100644 --- a/ishtar_common/utils.py +++ b/ishtar_common/utils.py @@ -62,6 +62,9 @@ class BColors: CSV_OPTIONS = {'delimiter': ',', 'quotechar': '"', 'quoting': QUOTE_ALL} +TXT_SEARCH_COMMENT = "key for text search (no accent, no spaces)" + + def check_rights(rights=None, redirect_url='/'): """ Decorator that checks the rights to access the view. diff --git a/ishtar_common/views_item.py b/ishtar_common/views_item.py index 9941f338c..854c91ce5 100644 --- a/ishtar_common/views_item.py +++ b/ishtar_common/views_item.py @@ -450,7 +450,11 @@ def _manage_bool_fields(model, bool_fields, reversed_bool_fields, dct, or_reqs): if dct[k] == u"1": dct.pop(k) else: - dct[k] = dct[k] == u"2" and True or False + dct[k] = dct[k].replace(u'"', u'') + if dct[k] in [u"2", u"yes", unicode(_(u"Yes")).lower()]: + dct[k] = True + else: + dct[k] = False if k in reversed_bool_fields: dct[k] = not dct[k] # check also for empty value with image field @@ -609,7 +613,8 @@ def _manage_hierarchic_fields(dct, and_reqs): def _manage_clean_search_field(dct): for k in dct: # clean quoted search field - dct[k] = dct[k].replace(u'"', '') + if type(dct[k]) == unicode: + dct[k] = dct[k].replace(u'"', '') def _manage_relation_types(relation_types, dct, query, or_reqs): @@ -656,7 +661,7 @@ def _contruct_query(relation_types, dct, or_reqs, and_reqs): # manage multi value not already managed for key in dct.keys(): - if ";" in dct[key]: + if type(dct[key]) == unicode and u";" in dct[key]: values = [v for v in dct[key].split(u';') if v] if not values: dct.pop(key) |