place/event matches
This commit is contained in:
parent
f23340ddbb
commit
4c25291c88
3 changed files with 16 additions and 6 deletions
|
|
@ -7,6 +7,7 @@ import re
|
|||
from django.db import models, transaction
|
||||
from django.contrib.auth.models import User, Group
|
||||
from django.db.models import Q
|
||||
from django.conf import settings
|
||||
import ox
|
||||
from ox.django import fields
|
||||
|
||||
|
|
@ -82,6 +83,8 @@ class Place(models.Model):
|
|||
return j
|
||||
|
||||
def get_matches(self):
|
||||
layers = filter(lambda l: l['type'] == 'place' or l.get('hasPlaces'),
|
||||
settings.CONFIG['layers'])
|
||||
super_matches = []
|
||||
q = Q(name_find__contains=" " + self.name)|Q(name_find__contains="|%s"%self.name)
|
||||
for name in self.alternativeNames:
|
||||
|
|
@ -95,7 +98,7 @@ class Place(models.Model):
|
|||
for name in self.alternativeNames:
|
||||
q = q|Q(value__icontains=" " + name)|Q(value__istartswith=name)
|
||||
matches = []
|
||||
for a in Annotation.objects.filter(q):
|
||||
for a in Annotation.objects.filter(layer__in=layers).filter(q):
|
||||
value = a.value.lower()
|
||||
for name in super_matches:
|
||||
value = value.replace(name.lower(), '')
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue