summaryrefslogtreecommitdiff
path: root/ishtar_common/views_item.py
diff options
context:
space:
mode:
authorÉtienne Loks <etienne.loks@iggdrasil.net>2023-05-09 17:52:08 +0200
committerÉtienne Loks <etienne.loks@iggdrasil.net>2023-05-09 17:52:08 +0200
commitc3309b29195d6c48914534360883acd543e23e20 (patch)
tree09567953848bbc095e1eaad8abb193993512e2af /ishtar_common/views_item.py
parent88051c68f3fba47bf37aee7b0cb6763f04f33a02 (diff)
downloadIshtar-c3309b29195d6c48914534360883acd543e23e20.tar.bz2
Ishtar-c3309b29195d6c48914534360883acd543e23e20.zip
Fix container search for documents
Diffstat (limited to 'ishtar_common/views_item.py')
-rw-r--r--ishtar_common/views_item.py20
1 files changed, 18 insertions, 2 deletions
diff --git a/ishtar_common/views_item.py b/ishtar_common/views_item.py
index 31a96f270..e2214d5dc 100644
--- a/ishtar_common/views_item.py
+++ b/ishtar_common/views_item.py
@@ -1066,12 +1066,28 @@ def _manage_hierarchic_fields(model, dct, and_reqs):
# TODO: improve query with "IN ()"?
continue
- if req.endswith("precise_town_id__cached_label"):
+ if req.endswith("wcontainer_id") or req.endswith("wcontainer_ref_id"):
+ val = _clean_type_val(dct.pop(req)).strip('"')
+ if val.startswith('"') and val.endswith('"'):
+ val = val[1:-1]
+ vals = [v.replace('"', "") for v in val.split(";")]
+ container_ids = []
+ for val in vals:
+ q = Container.objects.filter(cached_label__iexact=val).values_list(
+ "id", flat=True)
+ if not q.count():
+ continue
+ container_id = q.all()[0]
+ container_ids.append(container_id)
+ req = req[1:] # remove "w"
+ main_req = Q(**{req + "__in": container_ids})
+ and_reqs.append(main_req)
+
+ if req.endswith("precise_town_id"):
val = _clean_type_val(dct.pop(req)).strip('"')
if val.startswith('"') and val.endswith('"'):
val = val[1:-1]
vals = [v.replace('"', "") for v in val.split(";")]
- req = req[:-len("__cached_label")]
town_ids = []
for val in vals:
q = models.Town.objects.filter(cached_label__iexact=val).values_list(