From 4f8d53a3c8da171e699857dc58003db5018d0fac Mon Sep 17 00:00:00 2001 From: Edward <9326037+edwardoliveira@users.noreply.github.com> Date: Fri, 1 Jul 2022 12:45:26 -0300 Subject: [PATCH] Ajusta norma pendente (#3578) --- .../migrations/0019_auto_20220630_1420.py | 44 +++++++++++++++++++ sapl/compilacao/models.py | 12 ++--- sapl/norma/models.py | 1 + 3 files changed, 51 insertions(+), 6 deletions(-) create mode 100644 sapl/compilacao/migrations/0019_auto_20220630_1420.py diff --git a/sapl/compilacao/migrations/0019_auto_20220630_1420.py b/sapl/compilacao/migrations/0019_auto_20220630_1420.py new file mode 100644 index 000000000..8de4dcce3 --- /dev/null +++ b/sapl/compilacao/migrations/0019_auto_20220630_1420.py @@ -0,0 +1,44 @@ +# Generated by Django 2.2.24 on 2022-06-30 17:20 + +from django.db import migrations, models +import django.db.models.deletion + + +class Migration(migrations.Migration): + + dependencies = [ + ('compilacao', '0018_auto_20210227_2152'), + ] + + operations = [ + migrations.AlterField( + model_name='dispositivo', + name='dispositivo_atualizador', + field=models.ForeignKey(blank=True, default=None, null=True, on_delete=django.db.models.deletion.SET_NULL, related_name='dispositivos_alterados_set', to='compilacao.Dispositivo', verbose_name='Dispositivo Atualizador'), + ), + migrations.AlterField( + model_name='dispositivo', + name='dispositivo_pai', + field=models.ForeignKey(blank=True, default=None, null=True, on_delete=django.db.models.deletion.CASCADE, related_name='dispositivos_filhos_set', to='compilacao.Dispositivo', verbose_name='Dispositivo Pai'), + ), + migrations.AlterField( + model_name='dispositivo', + name='dispositivo_raiz', + field=models.ForeignKey(blank=True, default=None, null=True, on_delete=django.db.models.deletion.CASCADE, related_name='nodes', to='compilacao.Dispositivo', verbose_name='Dispositivo Raiz'), + ), + migrations.AlterField( + model_name='dispositivo', + name='publicacao', + field=models.ForeignKey(blank=True, default=None, null=True, on_delete=django.db.models.deletion.SET_NULL, to='compilacao.Publicacao', verbose_name='Publicação'), + ), + migrations.AlterField( + model_name='dispositivo', + name='ta_publicado', + field=models.ForeignKey(blank=True, default=None, null=True, on_delete=django.db.models.deletion.CASCADE, related_name='dispositivos_alterados_pelo_ta_set', to='compilacao.TextoArticulado', verbose_name='Texto Articulado Publicado'), + ), + migrations.AlterField( + model_name='publicacao', + name='ta', + field=models.ForeignKey(on_delete=django.db.models.deletion.CASCADE, to='compilacao.TextoArticulado', verbose_name='Texto Articulado'), + ), + ] diff --git a/sapl/compilacao/models.py b/sapl/compilacao/models.py index 452d2a494..589f8377c 100644 --- a/sapl/compilacao/models.py +++ b/sapl/compilacao/models.py @@ -894,7 +894,7 @@ class Publicacao(TimestampedMixin): ta = models.ForeignKey( TextoArticulado, verbose_name=_('Texto Articulado'), - on_delete=models.PROTECT + on_delete=models.CASCADE ) veiculo_publicacao = models.ForeignKey( @@ -1104,7 +1104,7 @@ class Dispositivo(BaseModel, TimestampedMixin): null=True, default=None, verbose_name=_('Publicação'), - on_delete=models.PROTECT + on_delete=models.SET_NULL, ) ta = models.ForeignKey( @@ -1116,7 +1116,7 @@ class Dispositivo(BaseModel, TimestampedMixin): ta_publicado = models.ForeignKey( TextoArticulado, - on_delete=models.PROTECT, + on_delete=models.CASCADE, blank=True, null=True, default=None, @@ -1151,7 +1151,7 @@ class Dispositivo(BaseModel, TimestampedMixin): default=None, related_name='dispositivos_filhos_set', verbose_name=_('Dispositivo Pai'), - on_delete=models.PROTECT + on_delete=models.CASCADE, ) dispositivo_raiz = models.ForeignKey( @@ -1161,7 +1161,7 @@ class Dispositivo(BaseModel, TimestampedMixin): default=None, related_name='nodes', verbose_name=_('Dispositivo Raiz'), - on_delete=models.PROTECT + on_delete=models.CASCADE, ) dispositivo_vigencia = models.ForeignKey( @@ -1181,7 +1181,7 @@ class Dispositivo(BaseModel, TimestampedMixin): default=None, related_name='dispositivos_alterados_set', verbose_name=_('Dispositivo Atualizador'), - on_delete=models.PROTECT + on_delete=models.SET_NULL, ) contagem_continua = models.BooleanField( diff --git a/sapl/norma/models.py b/sapl/norma/models.py index 85358ed75..2e15cf333 100644 --- a/sapl/norma/models.py +++ b/sapl/norma/models.py @@ -120,6 +120,7 @@ class NormaJuridicaManager(models.Manager): if not count: ta.dispositivos_set.filter( dispositivo_pai__isnull=False).delete() + ta.publicacao_set.all().delete() ta.delete() return qs