summaryrefslogtreecommitdiff
path: root/ishtar_common/views_item.py
diff options
context:
space:
mode:
Diffstat (limited to 'ishtar_common/views_item.py')
-rw-r--r--ishtar_common/views_item.py20
1 files changed, 15 insertions, 5 deletions
diff --git a/ishtar_common/views_item.py b/ishtar_common/views_item.py
index 374dc3927..da87ef02f 100644
--- a/ishtar_common/views_item.py
+++ b/ishtar_common/views_item.py
@@ -542,18 +542,28 @@ def _manage_hierarchic_fields(dct, and_reqs):
if type(reqs) not in (list, tuple):
reqs = [reqs]
for req in reqs:
- if req.endswith('areas__pk'):
+ if req.endswith('areas__pk') \
+ or req.endswith('areas__label__iexact'):
+ if req.endswith('pk'):
+ suffix = 'pk'
+ elif req.endswith('label__iexact'):
+ suffix = 'label__iexact'
+ else:
+ continue
+
val = _clean_type_val(dct.pop(req))
+ if val.startswith('"') and val.endswith('"'):
+ val = val[1:-1]
reqs = Q(**{req: val})
- base_req = req[:-2] + '__'
- req = base_req[:]
+ base_req = req[:]
+
for idx in range(HIERARCHIC_LEVELS):
- req = req[:-2] + 'parent__pk'
+ req = req[:-(len(suffix))] + 'parent__' + suffix
q = Q(**{req: val})
reqs |= q
req = base_req[:]
for idx in range(HIERARCHIC_LEVELS):
- req = req[:-2] + 'children__pk'
+ req = req[:-(len(suffix))] + 'children__' + suffix
q = Q(**{req: val})
reqs |= q
and_reqs.append(reqs)