diff options
author | Étienne Loks <etienne.loks@iggdrasil.net> | 2018-06-13 17:31:13 +0200 |
---|---|---|
committer | Étienne Loks <etienne.loks@iggdrasil.net> | 2018-06-13 17:31:13 +0200 |
commit | bcda82df67ff32d946ba13769af90af4d53a4355 (patch) | |
tree | 40e3e1ce072596d24f93f0e40a79631cf7a361d6 /ishtar_common | |
parent | d96282c864e81ac8501cfef67adf3d8b5d74cfa0 (diff) | |
download | Ishtar-bcda82df67ff32d946ba13769af90af4d53a4355.tar.bz2 Ishtar-bcda82df67ff32d946ba13769af90af4d53a4355.zip |
Manage area search for finds
Diffstat (limited to 'ishtar_common')
-rw-r--r-- | ishtar_common/views_item.py | 17 |
1 files changed, 17 insertions, 0 deletions
diff --git a/ishtar_common/views_item.py b/ishtar_common/views_item.py index 2018f6f90..1d3d55a5c 100644 --- a/ishtar_common/views_item.py +++ b/ishtar_common/views_item.py @@ -549,6 +549,23 @@ def get_item(model, func_name, default_name, extra_request_keys=[], dct.pop(k) # manage hierarchic conditions for req in dct.copy(): + if req.endswith('areas__pk'): + val = dct.pop(req) + reqs = Q(**{req: val}) + base_req = req[:-2] + '__' + req = base_req[:] + for idx in range(HIERARCHIC_LEVELS): + req = req[:-2] + 'parent__pk' + q = Q(**{req: val}) + reqs |= q + req = base_req[:] + for idx in range(HIERARCHIC_LEVELS): + req = req[:-2] + 'children__pk' + q = Q(**{req: val}) + reqs |= q + and_reqs.append(reqs) + continue + if req.endswith('town__pk') or req.endswith('towns__pk'): val = dct.pop(req) reqs = Q(**{req: val}) |