keep entity annotation find/sort values in sync with entities
This commit is contained in:
parent
7377de62f7
commit
deda6252f1
1 changed files with 8 additions and 1 deletions
|
@ -6,7 +6,7 @@ import re
|
||||||
from glob import glob
|
from glob import glob
|
||||||
from urllib import quote, unquote
|
from urllib import quote, unquote
|
||||||
|
|
||||||
from django.db import models
|
from django.db import models, transaction
|
||||||
from django.db.models import Max
|
from django.db.models import Max
|
||||||
from django.contrib.auth.models import User
|
from django.contrib.auth.models import User
|
||||||
from django.db.models.signals import pre_delete
|
from django.db.models.signals import pre_delete
|
||||||
|
@ -57,6 +57,7 @@ class Entity(models.Model):
|
||||||
self.name_find = '||' + self.name + '||'.join(self.alternativeNames) + '||'
|
self.name_find = '||' + self.name + '||'.join(self.alternativeNames) + '||'
|
||||||
super(Entity, self).save(*args, **kwargs)
|
super(Entity, self).save(*args, **kwargs)
|
||||||
self.update_matches()
|
self.update_matches()
|
||||||
|
self.update_annotations()
|
||||||
|
|
||||||
def __unicode__(self):
|
def __unicode__(self):
|
||||||
return self.get_id()
|
return self.get_id()
|
||||||
|
@ -182,6 +183,12 @@ class Entity(models.Model):
|
||||||
Entity.objects.filter(id=self.id).update(matches=matches)
|
Entity.objects.filter(id=self.id).update(matches=matches)
|
||||||
self.matches = matches
|
self.matches = matches
|
||||||
|
|
||||||
|
def update_annotations(self):
|
||||||
|
entity_layers = [l['id'] for l in settings.CONFIG['layers'] if l['type'] == 'entity']
|
||||||
|
if entity_layers:
|
||||||
|
with transaction.commit_on_success():
|
||||||
|
for a in annotation.models.Annotation.objects.filter(layer__in=entity_layers, value=self.get_id()):
|
||||||
|
a.save()
|
||||||
|
|
||||||
class DocumentProperties(models.Model):
|
class DocumentProperties(models.Model):
|
||||||
|
|
||||||
|
|
Loading…
Reference in a new issue