fix Places with umlaut in hasPlaces mode, fixes #2399

This commit is contained in:
j 2014-06-06 12:04:47 +00:00
parent e880bf4fcb
commit 9aa23e421d

View file

@ -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'])] contains = [l['id'] for l in filter(lambda l: l.get(has_type), settings.CONFIG['layers'])]
if contains: if contains:
name = ox.decode_html(obj.name) name = ox.decode_html(obj.name)
name = unicodedata.normalize('NFKD', name).lower()
q = Q(findvalue__icontains=" " + name)|Q(findvalue__istartswith=name) q = Q(findvalue__icontains=" " + name)|Q(findvalue__istartswith=name)
for name in obj.alternativeNames: for name in obj.alternativeNames:
name = ox.decode_html(name) name = ox.decode_html(name)
name = unicodedata.normalize('NFKD', name).lower()
q = q|Q(findvalue__icontains=" " + name)|Q(findvalue__istartswith=name) q = q|Q(findvalue__icontains=" " + name)|Q(findvalue__istartswith=name)
contains_matches = q&Q(layer__in=contains) contains_matches = q&Q(layer__in=contains)
if f: if f:
@ -70,6 +72,7 @@ def get_matches(obj, model, layer_type, qs=None):
for name in [obj.name] + list(obj.alternativeNames): for name in [obj.name] + list(obj.alternativeNames):
name = name.lower() name = name.lower()
name = ox.decode_html(name) 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)): if name in value and (exact or re.compile('((^|\s)%s([\.,;:!?\'"\)\]\-\/\s]|$))'%re.escape(name)).findall(value)):
matches.append(a.id) matches.append(a.id)
break break