dont fail if findvalue is not set
This commit is contained in:
parent
eb0c1d13ba
commit
3f2ba727bd
1 changed files with 11 additions and 10 deletions
|
@ -63,16 +63,17 @@ def get_matches(obj, model, layer_type, qs=None):
|
|||
if not qs:
|
||||
qs = Annotation.objects.all()
|
||||
for a in qs.filter(f):
|
||||
value = a.findvalue.lower()
|
||||
for name in super_matches:
|
||||
name = ox.decode_html(name)
|
||||
value = value.replace(name.lower(), '')
|
||||
for name in [obj.name] + list(obj.alternativeNames):
|
||||
name = name.lower()
|
||||
name = ox.decode_html(name)
|
||||
if name in value and (exact or re.compile('((^|\s)%s([\.,;:!?\-\/\s]|$))'%re.escape(name)).findall(value)):
|
||||
matches.append(a.id)
|
||||
break
|
||||
if a.findvalue:
|
||||
value = a.findvalue.lower()
|
||||
for name in super_matches:
|
||||
name = ox.decode_html(name)
|
||||
value = value.replace(name.lower(), '')
|
||||
for name in [obj.name] + list(obj.alternativeNames):
|
||||
name = name.lower()
|
||||
name = ox.decode_html(name)
|
||||
if name in value and (exact or re.compile('((^|\s)%s([\.,;:!?\-\/\s]|$))'%re.escape(name)).findall(value)):
|
||||
matches.append(a.id)
|
||||
break
|
||||
if not matches:
|
||||
matches = [-1]
|
||||
return Annotation.objects.filter(id__in=matches)
|
||||
|
|
Loading…
Reference in a new issue