From 3f737a35a854c43fbbe0a0f9c9c61255472a1d55 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Vin=C3=ADcius=20Cantu=C3=A1ria?= Date: Fri, 5 Jun 2020 11:55:29 -0300 Subject: [PATCH] =?UTF-8?q?Adiciona=20exclus=C3=A3o=20de=20composi=C3=A7?= =?UTF-8?q?=C3=A3o=20(#3171)?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit * Adiciona exclusão de composição * Altera on_delete de comissão em Reunião --- .../migrations/0025_auto_20200605_1051.py | 21 +++++++++++++++++++ sapl/comissoes/models.py | 2 +- sapl/comissoes/views.py | 7 +++++++ sapl/templates/comissoes/composicao_list.html | 6 ++++++ 4 files changed, 35 insertions(+), 1 deletion(-) create mode 100644 sapl/comissoes/migrations/0025_auto_20200605_1051.py 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 +
+ + Excluir Composição de Comissão + +
{% endif %}