mirror of https://github.com/interlegis/sapl.git
You can not select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
28 lines
676 B
28 lines
676 B
from subprocess import PIPE, call
|
|
from threading import Thread
|
|
|
|
from django.db.models.signals import post_delete, post_save
|
|
|
|
from sapl.settings import PROJECT_DIR
|
|
|
|
from .models import NormaJuridica
|
|
|
|
|
|
class UpdateIndexCommand(Thread):
|
|
def run(self):
|
|
call([PROJECT_DIR.child('manage.py'), 'update_index'],
|
|
stdout=PIPE)
|
|
|
|
|
|
def save_texto(sender, instance, **kwargs):
|
|
update_index = UpdateIndexCommand()
|
|
update_index.start()
|
|
|
|
|
|
def delete_texto(sender, instance, **kwargs):
|
|
update_index = UpdateIndexCommand()
|
|
update_index.start()
|
|
|
|
|
|
post_save.connect(save_texto, sender=NormaJuridica)
|
|
post_delete.connect(delete_texto, sender=NormaJuridica)
|
|
|