Browse Source

Cria log do reversion quando objeto for deletado

Signed-off-by: Luciano Almeida <lucianoalmeida@interlegis.leg.br>
pull/900/head
Luciano Almeida 8 years ago
parent
commit
3be17d2cdf
  1. 12
      sapl/rules/apps.py

12
sapl/rules/apps.py

@ -10,6 +10,10 @@ from django.db import models, router
from django.db.utils import DEFAULT_DB_ALIAS from django.db.utils import DEFAULT_DB_ALIAS
from django.utils.translation import ugettext_lazy as _ from django.utils.translation import ugettext_lazy as _
from django.utils.translation import string_concat from django.utils.translation import string_concat
import django
from django.dispatch import receiver
from django.db.models.signals import pre_delete
import reversion
from sapl.rules import (SAPL_GROUP_ADMINISTRATIVO, SAPL_GROUP_COMISSOES, from sapl.rules import (SAPL_GROUP_ADMINISTRATIVO, SAPL_GROUP_COMISSOES,
SAPL_GROUP_GERAL, SAPL_GROUP_MATERIA, SAPL_GROUP_NORMA, SAPL_GROUP_GERAL, SAPL_GROUP_MATERIA, SAPL_GROUP_NORMA,
@ -233,3 +237,11 @@ models.signals.post_migrate.connect(
models.signals.post_migrate.connect( models.signals.post_migrate.connect(
receiver=create_proxy_permissions, receiver=create_proxy_permissions,
dispatch_uid="django.contrib.auth.management.create_permissions") dispatch_uid="django.contrib.auth.management.create_permissions")
@receiver(pre_delete)
def revision_pre_delete_signal(sender, **kwargs):
if sender.__name__ not in ['Version', 'Revision']:
with reversion.create_revision():
kwargs['instance'].save()
reversion.set_comment("Deletado.")

Loading…
Cancel
Save