From d2c210949ef59c138b9028e13ed2b1735e586dc7 Mon Sep 17 00:00:00 2001 From: Étienne Loks Date: Fri, 10 Jan 2020 15:46:26 +0100 Subject: Search: bad hierarchy check --- ishtar_common/views_item.py | 9 +++------ 1 file changed, 3 insertions(+), 6 deletions(-) (limited to 'ishtar_common') diff --git a/ishtar_common/views_item.py b/ishtar_common/views_item.py index 88cd70b43..431135e37 100644 --- a/ishtar_common/views_item.py +++ b/ishtar_common/views_item.py @@ -816,18 +816,13 @@ def _manage_hierarchic_fields(dct, and_reqs): if val.startswith('"') and val.endswith('"'): val = val[1:-1] reqs = Q(**{req: val}) - base_req = req[:] for idx in range(HIERARCHIC_LEVELS): req = req[:-(len(suffix))] + 'parent__' + suffix q = Q(**{req: val}) reqs |= q - req = base_req[:] - for idx in range(HIERARCHIC_LEVELS): - req = req[:-(len(suffix))] + 'children__' + suffix - q = Q(**{req: val}) - reqs |= q and_reqs.append(reqs) + # TODO: improve query with "IN ()"? continue if req.endswith('town__pk') or req.endswith('towns__pk') \ @@ -855,6 +850,7 @@ def _manage_hierarchic_fields(dct, and_reqs): q = Q(**{req: val}) reqs |= q and_reqs.append(reqs) + # TODO: improve query with "IN ()"? continue for k_hr in HIERARCHIC_FIELDS: @@ -908,6 +904,7 @@ def _manage_hierarchic_fields(dct, and_reqs): req = req[:-(len(suffix))] + 'parent__' + suffix q = Q(**{req: val}) reqs |= q + # TODO: improve query with "IN ()"? if reqs: and_reqs.append(reqs) break -- cgit v1.2.3