diff --git a/sapl/comissoes/migrations/0025_auto_20200605_1051.py b/sapl/comissoes/migrations/0025_auto_20200605_1051.py new file mode 100644 index 000000000..6415889d2 --- /dev/null +++ b/sapl/comissoes/migrations/0025_auto_20200605_1051.py @@ -0,0 +1,21 @@ +# -*- coding: utf-8 -*- +# Generated by Django 1.11.29 on 2020-06-05 13:51 +from __future__ import unicode_literals + +from django.db import migrations, models +import django.db.models.deletion + + +class Migration(migrations.Migration): + + dependencies = [ + ('comissoes', '0024_auto_20200602_0915'), + ] + + operations = [ + migrations.AlterField( + model_name='reuniao', + name='comissao', + field=models.ForeignKey(on_delete=django.db.models.deletion.CASCADE, to='comissoes.Comissao', verbose_name='Comissão'), + ), + ] diff --git a/sapl/comissoes/models.py b/sapl/comissoes/models.py index 9826c9848..bd46582ed 100644 --- a/sapl/comissoes/models.py +++ b/sapl/comissoes/models.py @@ -216,7 +216,7 @@ class Reuniao(models.Model): verbose_name=_('Periodo da Composicão da Comissão')) comissao = models.ForeignKey( Comissao, - on_delete=models.PROTECT, + on_delete=models.CASCADE, verbose_name=_('Comissão')) numero = models.PositiveIntegerField(verbose_name=_('Número')) nome = models.CharField( diff --git a/sapl/comissoes/views.py b/sapl/comissoes/views.py index 458a9a25f..019cca739 100644 --- a/sapl/comissoes/views.py +++ b/sapl/comissoes/views.py @@ -150,6 +150,13 @@ class ComposicaoCrud(MasterDetailCrud): ).order_by('-titular', 'cargo__id_ordenacao', 'id') return context + class DeleteView(MasterDetailCrud.DeleteView): + def delete(self, *args, **kwargs): + composicao = self.get_object() + composicao.delete() + return HttpResponseRedirect( + reverse('sapl.comissoes:composicao_list', kwargs={'pk': composicao.comissao.pk})) + class ComissaoCrud(Crud): model = Comissao diff --git a/sapl/templates/comissoes/composicao_list.html b/sapl/templates/comissoes/composicao_list.html index d3080d878..5c96ae8e5 100644 --- a/sapl/templates/comissoes/composicao_list.html +++ b/sapl/templates/comissoes/composicao_list.html @@ -38,6 +38,12 @@ Adicionar Participação em Comissão +
{% endif %}