Browse Source

Valida remoção ou retorno de proposição

pull/440/head
Eduardo Edson Batista Cordeiro Alves 9 years ago
parent
commit
7b37223f11
  1. 15
      materia/views.py
  2. 40
      templates/materia/proposicao_detail.html

15
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

40
templates/materia/proposicao_detail.html

@ -0,0 +1,40 @@
{% extends "base.html" %}
{% load i18n %}
{% block base_content %}
<div class="clearfix">
{% block actions %}
<div class="actions btn-group pull-right" role="group">
{% if proposicao.data_envio %}
<a href="{{ view.update_url }}" class="btn btn-default">{% trans 'Editar Proposição' %}</a>
<a href="{{ view.delete_url }}" class="btn btn-default">{% trans 'Retornar Proposição' %}</a>
{% else %}
<a href="{{ view.update_url }}" class="btn btn-default">{% trans 'Enviar/Editar Proposição' %}</a>
<a href="{{ view.delete_url }}" class="btn btn-default">{% trans 'Excluir Proposição' %}</a>
{% endif %}
</div>
{% endblock actions %}
</div>
{% block detail_content %}
{% for fieldset in view.layout_display %}
<h2 class="legend">{{ fieldset.legend }}</h2>
{% for row in fieldset.rows %}
<div class="row-fluid">
{% for column in row %}
<div class="col-sm-{{ column.span }}">
<div id="div_id_{{ column.id }}" class="form-group">
<p class="control-label">{{ column.verbose_name }}</p>
<div class="controls">
<p class="form-control-static">{{ column.text|safe }}</p>
</div>
</div>
</div>
{% endfor %}
</div>
{% endfor %}
{% endfor %}
{% endblock detail_content %}
{% endblock base_content %}
Loading…
Cancel
Save