dont fail if findvalue is not set

This commit is contained in:
j 2013-01-12 08:12:11 +00:00
parent eb0c1d13ba
commit 3f2ba727bd

View file

@ -63,16 +63,17 @@ def get_matches(obj, model, layer_type, qs=None):
if not qs: if not qs:
qs = Annotation.objects.all() qs = Annotation.objects.all()
for a in qs.filter(f): for a in qs.filter(f):
value = a.findvalue.lower() if a.findvalue:
for name in super_matches: value = a.findvalue.lower()
name = ox.decode_html(name) for name in super_matches:
value = value.replace(name.lower(), '') name = ox.decode_html(name)
for name in [obj.name] + list(obj.alternativeNames): value = value.replace(name.lower(), '')
name = name.lower() for name in [obj.name] + list(obj.alternativeNames):
name = ox.decode_html(name) name = name.lower()
if name in value and (exact or re.compile('((^|\s)%s([\.,;:!?\-\/\s]|$))'%re.escape(name)).findall(value)): name = ox.decode_html(name)
matches.append(a.id) if name in value and (exact or re.compile('((^|\s)%s([\.,;:!?\-\/\s]|$))'%re.escape(name)).findall(value)):
break matches.append(a.id)
break
if not matches: if not matches:
matches = [-1] matches = [-1]
return Annotation.objects.filter(id__in=matches) return Annotation.objects.filter(id__in=matches)