diff options
Diffstat (limited to 'ishtar_common/views_item.py')
-rw-r--r-- | ishtar_common/views_item.py | 20 |
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( |