From 06790f9bb9dc079d170a30ab10414f790e97edc0 Mon Sep 17 00:00:00 2001 From: Étienne Loks Date: Mon, 15 Feb 2021 11:46:11 +0100 Subject: Container autocomplete: fix strange names... --- archaeological_warehouse/views.py | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) (limited to 'archaeological_warehouse') diff --git a/archaeological_warehouse/views.py b/archaeological_warehouse/views.py index a9d1bf409..73951cffa 100644 --- a/archaeological_warehouse/views.py +++ b/archaeological_warehouse/views.py @@ -113,7 +113,7 @@ def autocomplete_container(request, warehouse_id=None): containers += list(models.Container.objects.filter( query).values('id', 'cached_label')[:limit]) limit = 15 - len(containers) - splitted = [s.lower() for s in term.split(' ') if s] + splitted = [s.lower() for s in term.split(' ') if s and s != '|'] if limit > 0 and len(splitted) > 1: type_positions = [] # container_type ID, pos inf, pos sup @@ -159,7 +159,8 @@ def autocomplete_container(request, warehouse_id=None): value = " ".join(splitted[pos_sup:]) else: value = " ".join(splitted[pos_sup:type_positions[idx + 1][1]]) - groups.append((container_type_id, value)) + if value: + groups.append((container_type_id, value)) if groups: query = base_query for idx, g in enumerate(reversed(groups)): -- cgit v1.2.3