From a9d9a7ca6355280d9e6ef38be19844e6cd1b7dde Mon Sep 17 00:00:00 2001 From: j <0x006A@0x2620.org> Date: Sun, 30 Oct 2011 15:27:26 +0100 Subject: [PATCH] make places case-insensitive too --- pandora/place/models.py | 7 ++++--- 1 file changed, 4 insertions(+), 3 deletions(-) diff --git a/pandora/place/models.py b/pandora/place/models.py index 31ed45f40..03d313357 100644 --- a/pandora/place/models.py +++ b/pandora/place/models.py @@ -78,13 +78,14 @@ class Place(models.Model): return j def get_matches(self): - q = Q(value__contains=" " + self.name)|Q(value__startswith=self.name) + q = Q(value__icontains=" " + self.name)|Q(value__istartswith=self.name) for name in self.alternativeNames: - q = q|Q(value__contains=" " + name)|Q(value__startswith=name) + q = q|Q(value__icontains=" " + name)|Q(value__istartswith=name) matches = [] for a in Annotation.objects.filter(q): - value = a.value + value = a.value.lower() for name in [self.name] + list(self.alternativeNames): + name = name.lower() if name in value and (value.startswith(name) or \ value.endswith(name) or \ re.compile('\s%s[\.,;:!?\-\/\s]'%name).findall(value)):