diff --git a/sapl/base/forms.py b/sapl/base/forms.py index 9d8d4534d..d7f1f3a4c 100644 --- a/sapl/base/forms.py +++ b/sapl/base/forms.py @@ -37,6 +37,38 @@ class RangeWidgetOverride(forms.MultiWidget): return ''.join(rendered_widgets) +class RelatorioMateriasTramitacaoilterSet(django_filters.FilterSet): + + ano = django_filters.ChoiceFilter(required=True, + label=u'Ano da Matéria', + choices=RANGE_ANOS) + + class Meta: + model = MateriaLegislativa + fields = ['ano', 'tipo', 'tramitacao__unidade_tramitacao_local', + 'tramitacao__status'] + + + def __init__(self, *args, **kwargs): + super(RelatorioMateriasTramitacaoilterSet, self).__init__( + *args, **kwargs) + + self.filters['tipo'].label = 'Tipo de Matéria' + + row1 = to_row([('ano', 12)]) + row2 = to_row([('tipo', 12)]) + row3 = to_row([('tramitacao__unidade_tramitacao_local', 12)]) + row4 = to_row([('tramitacao__status', 12)]) + + self.form.helper = FormHelper() + self.form.helper.form_method = 'GET' + self.form.helper.layout = Layout( + Fieldset(_('Pesquisa de Matéria em Tramitação'), + row1, row2, row3, row4, + form_actions(save_label='Pesquisar')) + ) + + class RelatorioMateriasPorAnoAutorTipoFilterSet(django_filters.FilterSet): ano = django_filters.ChoiceFilter(required=True, diff --git a/sapl/base/urls.py b/sapl/base/urls.py index a60e0d718..a59a1f924 100644 --- a/sapl/base/urls.py +++ b/sapl/base/urls.py @@ -6,7 +6,8 @@ from .apps import AppConfig from .forms import LoginForm from .views import (CasaLegislativaCrud, HelpView, RelatorioMateriasPorAnoAutorTipoView, - RelatorioMateriasPorAutorView) + RelatorioMateriasPorAutorView, + RelatorioMateriasTramitacaoView) app_name = AppConfig.name @@ -31,4 +32,7 @@ urlpatterns = [ url(r'^relatorio/materia-por-ano-autor-tipo$', RelatorioMateriasPorAnoAutorTipoView.as_view(), name='materia_por_ano_autor_tipo'), + url(r'^relatorio/materia-por-tramitacao$', + RelatorioMateriasTramitacaoView.as_view(), + name='materia_por_tramitacao'), ] diff --git a/sapl/base/views.py b/sapl/base/views.py index 06d48a5a6..2f44fe039 100644 --- a/sapl/base/views.py +++ b/sapl/base/views.py @@ -12,7 +12,8 @@ from sapl.utils import permissao_tb_aux from .forms import (CasaLegislativaForm, RelatorioMateriasPorAnoAutorTipoFilterSet, - RelatorioMateriasPorAutorFilterSet) + RelatorioMateriasPorAutorFilterSet, + RelatorioMateriasTramitacaoilterSet) from .models import CasaLegislativa @@ -20,6 +21,31 @@ def get_casalegislativa(): return CasaLegislativa.objects.first() +class RelatorioMateriasTramitacaoView(FilterView): + model = MateriaLegislativa + filterset_class = RelatorioMateriasTramitacaoilterSet + template_name = 'base/RelatorioMateriasPorTramitacao_filter.html' + + def get_context_data(self, **kwargs): + context = super(RelatorioMateriasTramitacaoView, + self).get_context_data(**kwargs) + + context['title'] = _('Matérias por Ano, Autor e Tipo') + + qtdes = {} + for tipo in TipoMateriaLegislativa.objects.all(): + qs = kwargs['object_list'] + qtde = len(qs.filter(tipo_id=tipo.id)) + if qtde > 0: + qtdes[tipo] = qtde + context['qtdes'] = qtdes + + qr = self.request.GET.copy() + context['filter_url'] = ('&' + qr.urlencode()) if len(qr) > 0 else '' + + return context + + class RelatorioMateriasPorAnoAutorTipoView(FilterView): model = MateriaLegislativa filterset_class = RelatorioMateriasPorAnoAutorTipoFilterSet diff --git a/sapl/templates/base/RelatorioMateriasPorTramitacao_filter.html b/sapl/templates/base/RelatorioMateriasPorTramitacao_filter.html new file mode 100644 index 000000000..9e7b15771 --- /dev/null +++ b/sapl/templates/base/RelatorioMateriasPorTramitacao_filter.html @@ -0,0 +1,60 @@ +{% extends "crud/list.html" %} +{% load i18n %} +{% load crispy_forms_tags %} + +{% block base_content %} + {% if not filter_url %} + {% crispy filter.form %} + {% endif %} + + {% if filter_url %} +
+ {% trans 'Fazer nova pesquisa' %} +
+



+ + + + + + + + + + + {% for key, value in qtdes.items %} + + + + + {% endfor %} + +
QUADRO GERAL
Tipo MatériaQuantidade
{{key.sigla}} - {{key}}{{value}}
+ + + + + + + + + + + {% for materia in object_list %} + + + + + + {% endfor %} + +
MatériaEmentaAutor(es)
+ {{materia.tipo.descricao}} - {{materia.tipo.sigla}} {{materia.numero}}/{{materia.ano}} + {{materia.ementa}} + {% for autor in materia.autoria_set.all %} + {{autor.autor}}
+ {% endfor %} +
+ {% endif %} + +{% endblock base_content %} diff --git a/sapl/templates/base/relatorios_list.html b/sapl/templates/base/relatorios_list.html index 849ef20d2..44cefb933 100644 --- a/sapl/templates/base/relatorios_list.html +++ b/sapl/templates/base/relatorios_list.html @@ -13,7 +13,7 @@ - Matérias em tramitação + Matérias em tramitação Matérias Legislativas por Ano, Tipo, Local atual e Status da Tramitação informados.