zoo_meta: reconstruit les index via les signaux (#19092)

Soit après un signal post_save sur un schéma soit après une migration.
This commit is contained in:
Benjamin Dauvergne 2018-01-25 21:21:10 +01:00 committed by Thomas NOEL
parent 9c8086e6d9
commit 0884695546
2 changed files with 16 additions and 4 deletions

View File

@ -15,9 +15,25 @@
# along with this program. If not, see <http://www.gnu.org/licenses/>.
from django.utils.translation import ugettext_lazy as _
from django.db.models.signals import post_migrate, post_save
from django.apps import AppConfig
class ZooMetaAppConfig(AppConfig):
name = 'zoo.zoo_meta'
verbose_name = _('metadatas')
def post_migrate(self, **kwargs):
from .models import EntitySchema
for schema in EntitySchema.objects.all():
schema.rebuild_indexes()
def post_save(self, sender, instance, **kwargs):
instance.rebuild_indexes()
def ready(self):
from .models import EntitySchema
post_migrate.connect(self.post_migrate)
post_save.connect(self.post_save, sender=EntitySchema)

View File

@ -116,10 +116,6 @@ class CommonSchema(models.Model):
objects = GetBySlugManager()
def save(self, *args, **kwargs):
super(CommonSchema, self).save(*args, **kwargs)
self.rebuild_indexes()
def make_caption(self, value):
if self.caption_template:
try: