From 5e6ab14131471e26f1664a10cfa1c1b2543894bf Mon Sep 17 00:00:00 2001 From: Eduardo Edson Batista Cordeiro Alves Date: Tue, 21 Feb 2017 14:26:33 -0300 Subject: [PATCH] Fix #633 --- sapl/comissoes/views.py | 20 ++++++ sapl/templates/comissoes/composicao_list.html | 69 +++++++++++++++++++ 2 files changed, 89 insertions(+) create mode 100644 sapl/templates/comissoes/composicao_list.html diff --git a/sapl/comissoes/views.py b/sapl/comissoes/views.py index 0f767cbea..adbaad6f4 100644 --- a/sapl/comissoes/views.py +++ b/sapl/comissoes/views.py @@ -42,6 +42,26 @@ class ComposicaoCrud(MasterDetailCrud): model_set = 'participacao_set' public = [RP_LIST, RP_DETAIL, ] + class ListView(MasterDetailCrud.ListView): + template_name = "comissoes/composicao_list.html" + paginate_by = None + + def take_composicao_pk(self): + try: + return int(self.request.GET['pk']) + except: + return 0 + + def get_context_data(self, **kwargs): + context = super().get_context_data(**kwargs) + context['composicao_pk'] = context['composicao_list'].first( + ).pk if self.take_composicao_pk( + ) == 0 else self.take_composicao_pk() + context['participacao_set'] = Participacao.objects.filter( + composicao__pk=context['composicao_pk'] + ).order_by('parlamentar') + return context + class ComissaoCrud(Crud): model = Comissao diff --git a/sapl/templates/comissoes/composicao_list.html b/sapl/templates/comissoes/composicao_list.html new file mode 100644 index 000000000..7d30ae875 --- /dev/null +++ b/sapl/templates/comissoes/composicao_list.html @@ -0,0 +1,69 @@ +{% extends "crud/list.html" %} +{% load i18n common_tags crispy_forms_tags%} + +{% block base_content %} +
+ {% block actions %} +
+ {% if view.create_url %} + + {% blocktrans with verbose_name=view.verbose_name %} Adicionar {{ verbose_name }} {% endblocktrans %} + + {% endif %} + {% block more_buttons %}{% endblock more_buttons %} +
+ {% endblock actions %} +
+ +
+ Selecione o Período +
+ +
+
+
+ +
+ + Adicionar Participação em Comissão + +
+
+ +
+ + + + + + + + + + + + + + {% for p in participacao_set %} + + + + + + + + + + {% endfor %} + + +
+{% endblock base_content %}