Entity: only update annotations when name has changed (fixes #2877)

Just like ace0468 this doesn't exactly fix #2827, but it does reduce the
unnecessary work.
This commit is contained in:
Will Thompson 2016-02-04 18:35:33 +00:00 committed by j
parent 6008f3b44e
commit 691b3fa934
1 changed files with 14 additions and 1 deletions

View File

@ -10,7 +10,7 @@ import unicodedata
from django.db import models, transaction
from django.db.models import Max
from django.contrib.auth.models import User
from django.db.models.signals import pre_delete
from django.db.models.signals import pre_delete, post_init
from django.conf import settings
import ox
@ -232,11 +232,24 @@ class Entity(models.Model):
import annotation.models
import annotation.tasks
if self.name == self._original_name:
return
entity_layers = [l['id'] for l in settings.CONFIG['layers'] if l['type'] == 'entity']
if entity_layers:
annotation.tasks.update_annotations.delay(entity_layers, self.get_id())
def entity_post_init(sender, instance, **kwargs):
instance._original_name = instance.name
post_init.connect(
entity_post_init,
sender=Entity,
)
class DocumentProperties(models.Model):
class Meta: