diff --git a/comissoes/views.py b/comissoes/views.py index 42da7e302..e7315e9ae 100644 --- a/comissoes/views.py +++ b/comissoes/views.py @@ -1,12 +1,13 @@ +from django import forms from django.utils.translation import ugettext_lazy as _ - -from sapl.crud import build_crud - -from .models import CargoComissao, Comissao, Periodo, TipoComissao - +from django.views.generic import ListView from django.views.generic.edit import FormMixin +from sapl.crud import build_crud from vanilla import GenericView +from .models import (CargoComissao, Comissao, Composicao, Participacao, + Periodo, TipoComissao) + cargo_crud = build_crud( CargoComissao, 'cargo_comissao', [ @@ -58,9 +59,39 @@ comissao_crud = build_crud( ]) -class ComposicaoView(comissao_crud.CrudDetailView): +class ComposicaoForm(forms.Form): + periodo = forms.CharField() + + +class ComposicaoView(FormMixin, GenericView): template_name = 'comissoes/composicao.html' + def get(self, request, *args, **kwargs): + form = ComposicaoForm() + + composicoes = Composicao.objects.filter( + comissao_id=self.kwargs['pk']).order_by('-periodo') + participacoes = Participacao.objects.all() + + return self.render_to_response({ + 'participacoes': participacoes, + 'composicoes': composicoes, + 'composicao_id': composicoes.first().id, + 'form': form}) + + def post(self, request, *args, **kwargs): + form = ComposicaoForm(request.POST) + + composicoes = Composicao.objects.filter( + comissao_id=self.kwargs['pk']).order_by('-periodo') + participacoes = Participacao.objects.all() + + return self.render_to_response({ + 'participacoes': participacoes, + 'composicoes': composicoes, + 'composicao_id': int(form.data['periodo']), + 'form': form}) + class MateriasView(comissao_crud.CrudDetailView): template_name = 'comissoes/materias.html' @@ -70,7 +101,5 @@ class ReunioesView(comissao_crud.CrudDetailView): template_name = 'comissoes/reunioes.html' -class ComissaoParlamentarIncluirView(GenericView): - - template_name = "comissoes/comissao_parlamentar.html" - +class ComissaoParlamentarIncluirView(comissao_crud.CrudDetailView): + template_name = "comissoes/comissao_parlamentar.html" diff --git a/templates/comissoes/comissao_detail.html b/templates/comissoes/comissao_detail.html index 84e7213f6..bd1afdc6b 100644 --- a/templates/comissoes/comissao_detail.html +++ b/templates/comissoes/comissao_detail.html @@ -3,9 +3,9 @@ {% block sections_nav %} {% endblock sections_nav %} diff --git a/templates/comissoes/comissao_parlamentar.html b/templates/comissoes/comissao_parlamentar.html index 5f4e1b1a0..bc46b5e31 100644 --- a/templates/comissoes/comissao_parlamentar.html +++ b/templates/comissoes/comissao_parlamentar.html @@ -2,7 +2,7 @@ {% load i18n %} {% load crispy_forms_tags %} -

Incluir Parlamentar

{% block detail_content %} +

Incluir Parlamentar

{% endblock detail_content %} \ No newline at end of file diff --git a/templates/comissoes/composicao.html b/templates/comissoes/composicao.html index e249633e4..f04047dd1 100644 --- a/templates/comissoes/composicao.html +++ b/templates/comissoes/composicao.html @@ -5,6 +5,43 @@

Composição

{% block detail_content %} + + + + + + + + + + + + + {% csrf_token %} + + + + {% for participacao in participacoes %} + {% if participacao.composicao_id == composicao_id %} + + + + + + + + + + {% endif %} + {% endfor %} +
NomeCargoTitularDesignaçãoDesligamentoMotivoObservação
{{participacao.parlamentar.nome_parlamentar}}{{participacao.cargo}}{{participacao.titular|yesno:"Sim,Não"}}{{participacao.data_designacao|date:"d/m/Y"}}{{participacao.data_desligamento|date:"d/m/Y"|default:"-"}}{{participacao.motivo_desligamento|default:"-"}}{{participacao.observacao|default:"-"}}
+ Incluir Parlamentar {% endblock detail_content %} \ No newline at end of file