From 09d2f9bdbc04d3603546ce18b974e98d44f7e2d7 Mon Sep 17 00:00:00 2001 From: Edward Ribeiro Date: Wed, 21 Feb 2018 11:56:13 -0300 Subject: [PATCH] HOT-FIX: adiciona o cascade models filhos dm parlamentar --- .../migrations/0019_auto_20180221_1155.py | 31 +++++++++++++++++++ sapl/parlamentares/models.py | 6 ++-- 2 files changed, 34 insertions(+), 3 deletions(-) create mode 100644 sapl/parlamentares/migrations/0019_auto_20180221_1155.py diff --git a/sapl/parlamentares/migrations/0019_auto_20180221_1155.py b/sapl/parlamentares/migrations/0019_auto_20180221_1155.py new file mode 100644 index 000000000..d669a0d30 --- /dev/null +++ b/sapl/parlamentares/migrations/0019_auto_20180221_1155.py @@ -0,0 +1,31 @@ +# -*- coding: utf-8 -*- +# Generated by Django 1.9.11 on 2018-02-21 14:55 +from __future__ import unicode_literals + +from django.db import migrations, models +import django.db.models.deletion + + +class Migration(migrations.Migration): + + dependencies = [ + ('parlamentares', '0018_auto_20180215_1015'), + ] + + operations = [ + migrations.AlterField( + model_name='dependente', + name='parlamentar', + field=models.ForeignKey(on_delete=django.db.models.deletion.CASCADE, to='parlamentares.Parlamentar'), + ), + migrations.AlterField( + model_name='filiacao', + name='parlamentar', + field=models.ForeignKey(on_delete=django.db.models.deletion.CASCADE, to='parlamentares.Parlamentar'), + ), + migrations.AlterField( + model_name='mandato', + name='parlamentar', + field=models.ForeignKey(on_delete=django.db.models.deletion.CASCADE, to='parlamentares.Parlamentar'), + ), + ] diff --git a/sapl/parlamentares/models.py b/sapl/parlamentares/models.py index fc8c22b5e..86e174f09 100644 --- a/sapl/parlamentares/models.py +++ b/sapl/parlamentares/models.py @@ -351,7 +351,7 @@ class Dependente(models.Model): tipo = models.ForeignKey(TipoDependente, on_delete=models.PROTECT, verbose_name=_('Tipo')) - parlamentar = models.ForeignKey(Parlamentar, on_delete=models.PROTECT) + parlamentar = models.ForeignKey(Parlamentar, on_delete=models.CASCADE) nome = models.CharField(max_length=150, verbose_name=_('Nome')) sexo = models.CharField( max_length=1, verbose_name=_('Sexo'), choices=SEXO_CHOICE) @@ -377,7 +377,7 @@ class Dependente(models.Model): @reversion.register() class Filiacao(models.Model): data = models.DateField(verbose_name=_('Data Filiação')) - parlamentar = models.ForeignKey(Parlamentar, on_delete=models.PROTECT) + parlamentar = models.ForeignKey(Parlamentar, on_delete=models.CASCADE) partido = models.ForeignKey(Partido, on_delete=models.PROTECT, verbose_name=_('Partido')) @@ -417,7 +417,7 @@ class TipoAfastamento(models.Model): @reversion.register() class Mandato(models.Model): - parlamentar = models.ForeignKey(Parlamentar, on_delete=models.PROTECT) + parlamentar = models.ForeignKey(Parlamentar, on_delete=models.CASCADE) tipo_afastamento = models.ForeignKey( TipoAfastamento, blank=True, null=True, on_delete=models.PROTECT) legislatura = models.ForeignKey(Legislatura, on_delete=models.PROTECT,