summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--archaeological_operations/tests.py12
-rw-r--r--ishtar_common/views_item.py6
2 files changed, 17 insertions, 1 deletions
diff --git a/archaeological_operations/tests.py b/archaeological_operations/tests.py
index 3f659ef3b..b5680a6fd 100644
--- a/archaeological_operations/tests.py
+++ b/archaeological_operations/tests.py
@@ -1814,6 +1814,18 @@ class OperationSearchTest(TestCase, OperationInitTest):
self._test_search(c, search_name_q, lbl, 1,
"Facet search with = and | characters")
+ def test_search_with_asterisk_inside_names(self):
+ c = Client()
+ c.login(username=self.username, password=self.password)
+ ope = self.operations[0]
+ ope_type = ope.operation_type
+ ope_type.label = 'label*with*asterisk'
+ ope_type.save()
+ search_name_q = str(pgettext("key for text search", u"type"))
+ nb = models.Operation.objects.filter(operation_type=ope_type).count()
+ self._test_search(c, search_name_q, ope_type.label, nb,
+ "Facet search with * characters")
+
def test_hierarchic_search(self):
ope = self.operations[1]
c = Client()
diff --git a/ishtar_common/views_item.py b/ishtar_common/views_item.py
index a2e0844ce..2fdda5efb 100644
--- a/ishtar_common/views_item.py
+++ b/ishtar_common/views_item.py
@@ -841,7 +841,11 @@ def _manage_clean_search_field(dct):
dct[k] = dct[k].replace(u'"', '')
dct[k] = _clean_type_val(dct[k])
if '*' in dct[k] and k.endswith('__iexact'):
- value = dct.pop(k).replace(u'*', u'')
+ value = dct.pop(k).strip()
+ if value.startswith(u"*"):
+ value = value[1:]
+ if value.endswith(u"*"):
+ value = value[:-1]
dct[k[:-len('__iexact')] + '__icontains'] = value