From 7b37223f114d9d5f03e7798d2495e0eb68ac6257 Mon Sep 17 00:00:00 2001 From: Eduardo Edson Batista Cordeiro Alves Date: Tue, 10 May 2016 12:47:43 -0300 Subject: [PATCH] =?UTF-8?q?Valida=20remo=C3=A7=C3=A3o=20ou=20retorno=20de?= =?UTF-8?q?=20proposi=C3=A7=C3=A3o?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- materia/views.py | 15 +++++++++ templates/materia/proposicao_detail.html | 40 ++++++++++++++++++++++++ 2 files changed, 55 insertions(+) create mode 100644 templates/materia/proposicao_detail.html diff --git a/materia/views.py b/materia/views.py index aff45ef9b..e903de246 100644 --- a/materia/views.py +++ b/materia/views.py @@ -90,6 +90,21 @@ class ProposicaoCrud(Crud): return [self._as_row(obj) for obj in object_list] + class DeleteView(MasterDetailCrud.DeleteView): + + def delete(self, request, *args, **kwargs): + proposicao = Proposicao.objects.get(id=self.kwargs['pk']) + + if not proposicao.data_envio: + proposicao.delete() + return HttpResponseRedirect(reverse('materia:proposicao_list')) + else: + proposicao.data_envio = None + proposicao.save() + return HttpResponseRedirect( + reverse('materia:proposicao_detail', + kwargs={'pk': proposicao.pk})) + class RelatoriaCrud(MasterDetailCrud): model = Relatoria diff --git a/templates/materia/proposicao_detail.html b/templates/materia/proposicao_detail.html new file mode 100644 index 000000000..7d506e05d --- /dev/null +++ b/templates/materia/proposicao_detail.html @@ -0,0 +1,40 @@ +{% extends "base.html" %} +{% load i18n %} + +{% block base_content %} + +
+ {% block actions %} + + {% endblock actions %} +
+ + {% block detail_content %} + {% for fieldset in view.layout_display %} +

{{ fieldset.legend }}

+ {% for row in fieldset.rows %} +
+ {% for column in row %} +
+
+

{{ column.verbose_name }}

+
+

{{ column.text|safe }}

+
+
+
+ {% endfor %} +
+ {% endfor %} + {% endfor %} + {% endblock detail_content %} + +{% endblock base_content %}