From 9aa23e421d7fefd0d5d4d7b7cd88e8f81cc72f45 Mon Sep 17 00:00:00 2001 From: j <0x006A@0x2620.org> Date: Fri, 6 Jun 2014 12:04:47 +0000 Subject: [PATCH] fix Places with umlaut in hasPlaces mode, fixes #2399 --- pandora/annotation/models.py | 3 +++ 1 file changed, 3 insertions(+) diff --git a/pandora/annotation/models.py b/pandora/annotation/models.py index da2ac481..8784cf6b 100644 --- a/pandora/annotation/models.py +++ b/pandora/annotation/models.py @@ -48,9 +48,11 @@ def get_matches(obj, model, layer_type, qs=None): contains = [l['id'] for l in filter(lambda l: l.get(has_type), settings.CONFIG['layers'])] if contains: name = ox.decode_html(obj.name) + name = unicodedata.normalize('NFKD', name).lower() q = Q(findvalue__icontains=" " + name)|Q(findvalue__istartswith=name) for name in obj.alternativeNames: name = ox.decode_html(name) + name = unicodedata.normalize('NFKD', name).lower() q = q|Q(findvalue__icontains=" " + name)|Q(findvalue__istartswith=name) contains_matches = q&Q(layer__in=contains) if f: @@ -70,6 +72,7 @@ def get_matches(obj, model, layer_type, qs=None): for name in [obj.name] + list(obj.alternativeNames): name = name.lower() name = ox.decode_html(name) + name = unicodedata.normalize('NFKD', name).lower() if name in value and (exact or re.compile('((^|\s)%s([\.,;:!?\'"\)\]\-\/\s]|$))'%re.escape(name)).findall(value)): matches.append(a.id) break