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 %} + +
{{ column.verbose_name }}
+{{ column.text|safe }}
+