From 8574382e3b430a3e212eb5555d9f1c7a3eccb54d Mon Sep 17 00:00:00 2001 From: Eduardo Edson Batista Cordeiro Alves Date: Mon, 29 Aug 2016 12:43:12 -0300 Subject: [PATCH 1/7] Cria telas de pesquisa e listagem da pesquisa --- sapl/base/forms.py | 76 ++++++++++++++++++- sapl/base/urls.py | 6 +- sapl/base/views.py | 42 +++++++++- sapl/materia/views.py | 5 -- .../RelatorioMateriasPorAutor_filter.html | 64 ++++++++++++++++ sapl/templates/base/relatorios_list.html | 14 ++-- 6 files changed, 190 insertions(+), 17 deletions(-) create mode 100644 sapl/templates/base/RelatorioMateriasPorAutor_filter.html diff --git a/sapl/base/forms.py b/sapl/base/forms.py index 5f69f086c..6fcdcf5de 100644 --- a/sapl/base/forms.py +++ b/sapl/base/forms.py @@ -1,14 +1,88 @@ +import django_filters +from crispy_forms.helper import FormHelper +from crispy_forms.layout import HTML, Button, Fieldset, Layout from django import forms from django.contrib.auth.forms import AuthenticationForm from django.core.exceptions import ValidationError +from django.db import models from django.forms import ModelForm +from django.utils.translation import ugettext_lazy as _ +from sapl.crispy_layout_mixin import form_actions, to_row +from sapl.materia.models import MateriaLegislativa from sapl.settings import MAX_IMAGE_UPLOAD_SIZE -from sapl.utils import ImageThumbnailFileInput +from sapl.utils import (RANGE_ANOS, ImageThumbnailFileInput, autor_label, + autor_modal) from .models import CasaLegislativa +class RangeWidgetOverride(forms.MultiWidget): + + def __init__(self, attrs=None): + widgets = (forms.DateInput(format='%d/%m/%Y', + attrs={'class': 'dateinput', + 'placeholder': 'Inicial'}), + forms.DateInput(format='%d/%m/%Y', + attrs={'class': 'dateinput', + 'placeholder': 'Final'})) + super(RangeWidgetOverride, self).__init__(widgets, attrs) + + def decompress(self, value): + if value: + return [value.start, value.stop] + return [None, None] + + def format_output(self, rendered_widgets): + return ''.join(rendered_widgets) + + +class RelatorioMateriasPorAutorFilterSet(django_filters.FilterSet): + + filter_overrides = {models.DateField: { + 'filter_class': django_filters.DateFromToRangeFilter, + 'extra': lambda f: { + 'label': '%s (%s)' % (f.verbose_name, _('Inicial - Final')), + 'widget': RangeWidgetOverride} + }} + + autoria__autor = django_filters.CharFilter(widget=forms.HiddenInput()) + + class Meta: + model = MateriaLegislativa + fields = ['tipo', 'data_apresentacao'] + + def __init__(self, *args, **kwargs): + super(RelatorioMateriasPorAutorFilterSet, self).__init__( + *args, **kwargs) + + self.filters['tipo'].label = 'Tipo de Matéria' + + row1 = to_row( + [('tipo', 12)]) + row2 = to_row( + [('data_apresentacao', 12)]) + row3 = to_row( + [('autoria__autor', 0), + (Button('pesquisar', + 'Pesquisar Autor', + css_class='btn btn-primary btn-sm'), 2), + (Button('limpar', + 'limpar Autor', + css_class='btn btn-primary btn-sm'), 10)]) + + self.form.helper = FormHelper() + self.form.helper.form_method = 'GET' + self.form.helper.layout = Layout( + Fieldset(_('Pesquisar'), + row1, row2, + HTML(autor_label), + HTML(autor_modal), + row3, + form_actions(save_label='Pesquisar')) + ) + + class CasaLegislativaForm(ModelForm): class Meta: diff --git a/sapl/base/urls.py b/sapl/base/urls.py index 03b5b4eb3..e7500d683 100644 --- a/sapl/base/urls.py +++ b/sapl/base/urls.py @@ -4,7 +4,7 @@ from django.views.generic.base import TemplateView from .apps import AppConfig from .forms import LoginForm -from .views import CasaLegislativaCrud, HelpView +from .views import CasaLegislativaCrud, HelpView, RelatorioMateriasPorAutorView app_name = AppConfig.name @@ -17,11 +17,13 @@ urlpatterns = [ url(r'^ajuda/(?P\w+)$', HelpView.as_view(), name='help_topic'), url(r'^ajuda/', TemplateView.as_view(template_name='ajuda/index.html'), name='help_base'), - url(r'^casa_legislativa/', include(CasaLegislativaCrud.get_urls())), url(r'^login/$', views.login, { 'template_name': 'base/login.html', 'authentication_form': LoginForm}, name='login'), url(r'^logout/$', views.logout, {'next_page': '/login'}, name='logout'), + + url(r'^relatorio/materia-por-autor$', + RelatorioMateriasPorAutorView.as_view(), name='materia_por_autor'), ] diff --git a/sapl/base/views.py b/sapl/base/views.py index c52b5b6fa..1e4ae15f1 100644 --- a/sapl/base/views.py +++ b/sapl/base/views.py @@ -1,13 +1,16 @@ from django.contrib.auth.mixins import PermissionRequiredMixin from django.core.urlresolvers import reverse from django.http import HttpResponseRedirect +from django.utils.translation import ugettext_lazy as _ from django.views.generic.base import TemplateView +from django_filters.views import FilterView from sapl.crud.base import (Crud, CrudBaseMixin, CrudCreateView, - CrudDetailView, CrudUpdateView) + CrudDetailView, CrudUpdateView, make_pagination) +from sapl.materia.models import MateriaLegislativa, TipoMateriaLegislativa from sapl.utils import permissao_tb_aux -from .forms import CasaLegislativaForm +from .forms import CasaLegislativaForm, RelatorioMateriasPorAutorFilterSet from .models import CasaLegislativa @@ -15,6 +18,41 @@ def get_casalegislativa(): return CasaLegislativa.objects.first() +class RelatorioMateriasPorAutorView(FilterView): + model = MateriaLegislativa + filterset_class = RelatorioMateriasPorAutorFilterSet + paginate_by = 10 + template_name = 'base/RelatorioMateriasPorAutor_filter.html' + + def get_filterset_kwargs(self, filterset_class): + super(RelatorioMateriasPorAutorView, + self).get_filterset_kwargs(filterset_class) + + kwargs = {'data': self.request.GET or None} + qs = self.get_queryset() + + return kwargs + + def get_context_data(self, **kwargs): + context = super(RelatorioMateriasPorAutorView, + self).get_context_data(**kwargs) + + context['title'] = _('Matérias por Autor') + + 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 CasaLegislativaCrud(Crud): model = CasaLegislativa help_path = '' diff --git a/sapl/materia/views.py b/sapl/materia/views.py index 35f4eef50..57a804be9 100644 --- a/sapl/materia/views.py +++ b/sapl/materia/views.py @@ -929,11 +929,6 @@ class MateriaLegislativaPesquisaView(FilterView): context['title'] = _('Pesquisar Matéria Legislativa') - paginator = context['paginator'] - page_obj = context['page_obj'] - context['page_range'] = make_pagination( - page_obj.number, paginator.num_pages) - self.filterset.form.fields['o'].label = _('Ordenação') qr = self.request.GET.copy() diff --git a/sapl/templates/base/RelatorioMateriasPorAutor_filter.html b/sapl/templates/base/RelatorioMateriasPorAutor_filter.html new file mode 100644 index 000000000..2df425be5 --- /dev/null +++ b/sapl/templates/base/RelatorioMateriasPorAutor_filter.html @@ -0,0 +1,64 @@ +{% extends "crud/list.html" %} +{% load i18n %} +{% load crispy_forms_tags %} + +{% block base_content %} + {% if not filter_url %} + {% crispy filter.form %} + {% endif %} + + {% if filter_url %} + +



+ + + + + + + + + + + {% 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.sigla}} {{materia.numero}}/{{materia.ano}} + {{materia.ementa}} + {% for autor in materia.autoria_set.all %} + {{autor.autor}}
+ {% endfor %} +
+ + {% include "paginacao.html" %} + + + {% endif %} + +{% endblock base_content %} diff --git a/sapl/templates/base/relatorios_list.html b/sapl/templates/base/relatorios_list.html index b4ffc0da3..d27a7914e 100644 --- a/sapl/templates/base/relatorios_list.html +++ b/sapl/templates/base/relatorios_list.html @@ -14,15 +14,15 @@ Matérias em tramitação - Matérias Legislativas por Ano, Tipo, Local atual e Status da Tramitação informados. + Matérias Legislativas por Ano, Tipo, Local atual e Status da Tramitação informados. - Proposituras por Tipo, Autor e Ano - Número de matérias legislativas, agrupadas por Tipo e Autor e Ano selecionado. + Matérias por Autor + Listagem e totalização de matérias por autor, com filtros para tipo e período. - Proposituras por Autor - Resumo de Proposituras de um determinado ano, agrupadas por Autor. + Matérias por Ano, Autor e Tipo + Totalização anual de matérias agrupadas por autor e tipo. Presença nas sessões @@ -30,11 +30,11 @@ Atas - Matérias Legislativas por Ano, Tipo, Local atual e Status da Tramitação informados. + Atas de Sessão Plenária. Histórico de tramitações - Histórico de tramitações por período e local informados. + Histórico de tramitações por período e local informados. From db1ac508e05e8dee4df09b4b2b8666661ac8fbeb Mon Sep 17 00:00:00 2001 From: Eduardo Edson Batista Cordeiro Alves Date: Mon, 29 Aug 2016 12:58:56 -0300 Subject: [PATCH 2/7] Fix qa --- sapl/base/forms.py | 3 +-- sapl/base/views.py | 5 +---- sapl/templates/base/RelatorioMateriasPorAutor_filter.html | 4 ---- 3 files changed, 2 insertions(+), 10 deletions(-) diff --git a/sapl/base/forms.py b/sapl/base/forms.py index 6fcdcf5de..085e6c4ea 100644 --- a/sapl/base/forms.py +++ b/sapl/base/forms.py @@ -11,8 +11,7 @@ from django.utils.translation import ugettext_lazy as _ from sapl.crispy_layout_mixin import form_actions, to_row from sapl.materia.models import MateriaLegislativa from sapl.settings import MAX_IMAGE_UPLOAD_SIZE -from sapl.utils import (RANGE_ANOS, ImageThumbnailFileInput, autor_label, - autor_modal) +from sapl.utils import ImageThumbnailFileInput, autor_label, autor_modal from .models import CasaLegislativa diff --git a/sapl/base/views.py b/sapl/base/views.py index 1e4ae15f1..719215d3e 100644 --- a/sapl/base/views.py +++ b/sapl/base/views.py @@ -6,7 +6,7 @@ from django.views.generic.base import TemplateView from django_filters.views import FilterView from sapl.crud.base import (Crud, CrudBaseMixin, CrudCreateView, - CrudDetailView, CrudUpdateView, make_pagination) + CrudDetailView, CrudUpdateView) from sapl.materia.models import MateriaLegislativa, TipoMateriaLegislativa from sapl.utils import permissao_tb_aux @@ -21,7 +21,6 @@ def get_casalegislativa(): class RelatorioMateriasPorAutorView(FilterView): model = MateriaLegislativa filterset_class = RelatorioMateriasPorAutorFilterSet - paginate_by = 10 template_name = 'base/RelatorioMateriasPorAutor_filter.html' def get_filterset_kwargs(self, filterset_class): @@ -29,8 +28,6 @@ class RelatorioMateriasPorAutorView(FilterView): self).get_filterset_kwargs(filterset_class) kwargs = {'data': self.request.GET or None} - qs = self.get_queryset() - return kwargs def get_context_data(self, **kwargs): diff --git a/sapl/templates/base/RelatorioMateriasPorAutor_filter.html b/sapl/templates/base/RelatorioMateriasPorAutor_filter.html index 2df425be5..889caf0f1 100644 --- a/sapl/templates/base/RelatorioMateriasPorAutor_filter.html +++ b/sapl/templates/base/RelatorioMateriasPorAutor_filter.html @@ -55,10 +55,6 @@ {% endfor %} - - {% include "paginacao.html" %} - - {% endif %} {% endblock base_content %} From 1af3b794ab41f10b2017286c4b93a43a019f3d5c Mon Sep 17 00:00:00 2001 From: Eduardo Edson Batista Cordeiro Alves Date: Thu, 1 Sep 2016 15:56:08 -0300 Subject: [PATCH 3/7] =?UTF-8?q?Adiciona=20tela=20de=20relat=C3=B3rio=20de?= =?UTF-8?q?=20mat=C3=A9ria=20por=20ano,=20autor=20e=20tipo?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- sapl/base/forms.py | 29 ++++++++- sapl/base/urls.py | 7 ++- sapl/base/views.py | 36 ++++++++++- ...latorioMateriasPorAnoAutorTipo_filter.html | 60 +++++++++++++++++++ sapl/templates/base/relatorios_list.html | 2 +- 5 files changed, 130 insertions(+), 4 deletions(-) create mode 100644 sapl/templates/base/RelatorioMateriasPorAnoAutorTipo_filter.html diff --git a/sapl/base/forms.py b/sapl/base/forms.py index 085e6c4ea..9d8d4534d 100644 --- a/sapl/base/forms.py +++ b/sapl/base/forms.py @@ -11,7 +11,8 @@ from django.utils.translation import ugettext_lazy as _ from sapl.crispy_layout_mixin import form_actions, to_row from sapl.materia.models import MateriaLegislativa from sapl.settings import MAX_IMAGE_UPLOAD_SIZE -from sapl.utils import ImageThumbnailFileInput, autor_label, autor_modal +from sapl.utils import (RANGE_ANOS, ImageThumbnailFileInput, autor_label, + autor_modal) from .models import CasaLegislativa @@ -36,6 +37,32 @@ class RangeWidgetOverride(forms.MultiWidget): return ''.join(rendered_widgets) +class RelatorioMateriasPorAnoAutorTipoFilterSet(django_filters.FilterSet): + + ano = django_filters.ChoiceFilter(required=True, + label=u'Ano da Matéria', + choices=RANGE_ANOS) + + class Meta: + model = MateriaLegislativa + fields = ['ano'] + + def __init__(self, *args, **kwargs): + super(RelatorioMateriasPorAnoAutorTipoFilterSet, self).__init__( + *args, **kwargs) + + row1 = to_row( + [('ano', 12)]) + + self.form.helper = FormHelper() + self.form.helper.form_method = 'GET' + self.form.helper.layout = Layout( + Fieldset(_('Pesquisar'), + row1, + form_actions(save_label='Pesquisar')) + ) + + class RelatorioMateriasPorAutorFilterSet(django_filters.FilterSet): filter_overrides = {models.DateField: { diff --git a/sapl/base/urls.py b/sapl/base/urls.py index e7500d683..a60e0d718 100644 --- a/sapl/base/urls.py +++ b/sapl/base/urls.py @@ -4,7 +4,9 @@ from django.views.generic.base import TemplateView from .apps import AppConfig from .forms import LoginForm -from .views import CasaLegislativaCrud, HelpView, RelatorioMateriasPorAutorView +from .views import (CasaLegislativaCrud, HelpView, + RelatorioMateriasPorAnoAutorTipoView, + RelatorioMateriasPorAutorView) app_name = AppConfig.name @@ -26,4 +28,7 @@ urlpatterns = [ url(r'^relatorio/materia-por-autor$', RelatorioMateriasPorAutorView.as_view(), name='materia_por_autor'), + url(r'^relatorio/materia-por-ano-autor-tipo$', + RelatorioMateriasPorAnoAutorTipoView.as_view(), + name='materia_por_ano_autor_tipo'), ] diff --git a/sapl/base/views.py b/sapl/base/views.py index 719215d3e..06d48a5a6 100644 --- a/sapl/base/views.py +++ b/sapl/base/views.py @@ -10,7 +10,9 @@ from sapl.crud.base import (Crud, CrudBaseMixin, CrudCreateView, from sapl.materia.models import MateriaLegislativa, TipoMateriaLegislativa from sapl.utils import permissao_tb_aux -from .forms import CasaLegislativaForm, RelatorioMateriasPorAutorFilterSet +from .forms import (CasaLegislativaForm, + RelatorioMateriasPorAnoAutorTipoFilterSet, + RelatorioMateriasPorAutorFilterSet) from .models import CasaLegislativa @@ -18,6 +20,38 @@ def get_casalegislativa(): return CasaLegislativa.objects.first() +class RelatorioMateriasPorAnoAutorTipoView(FilterView): + model = MateriaLegislativa + filterset_class = RelatorioMateriasPorAnoAutorTipoFilterSet + template_name = 'base/RelatorioMateriasPorAnoAutorTipo_filter.html' + + def get_filterset_kwargs(self, filterset_class): + super(RelatorioMateriasPorAnoAutorTipoView, + self).get_filterset_kwargs(filterset_class) + + kwargs = {'data': self.request.GET or None} + return kwargs + + def get_context_data(self, **kwargs): + context = super(RelatorioMateriasPorAnoAutorTipoView, + 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 RelatorioMateriasPorAutorView(FilterView): model = MateriaLegislativa filterset_class = RelatorioMateriasPorAutorFilterSet diff --git a/sapl/templates/base/RelatorioMateriasPorAnoAutorTipo_filter.html b/sapl/templates/base/RelatorioMateriasPorAnoAutorTipo_filter.html new file mode 100644 index 000000000..2498c08be --- /dev/null +++ b/sapl/templates/base/RelatorioMateriasPorAnoAutorTipo_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 %} + +



+ + + + + + + + + + + {% 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 d27a7914e..849ef20d2 100644 --- a/sapl/templates/base/relatorios_list.html +++ b/sapl/templates/base/relatorios_list.html @@ -21,7 +21,7 @@ Listagem e totalização de matérias por autor, com filtros para tipo e período. - Matérias por Ano, Autor e Tipo + Matérias por Ano, Autor e Tipo Totalização anual de matérias agrupadas por autor e tipo. From 207f8b19904e362ae153bc444a04146a3b6aeec1 Mon Sep 17 00:00:00 2001 From: Eduardo Edson Batista Cordeiro Alves Date: Thu, 1 Sep 2016 16:26:51 -0300 Subject: [PATCH 4/7] =?UTF-8?q?Adiciona=20tela=20de=20relat=C3=B3rio=20de?= =?UTF-8?q?=20mat=C3=A9ria=20por=20tramitacao?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- sapl/base/forms.py | 32 ++++++++++ sapl/base/urls.py | 6 +- sapl/base/views.py | 28 ++++++++- ...RelatorioMateriasPorTramitacao_filter.html | 60 +++++++++++++++++++ sapl/templates/base/relatorios_list.html | 2 +- 5 files changed, 125 insertions(+), 3 deletions(-) create mode 100644 sapl/templates/base/RelatorioMateriasPorTramitacao_filter.html 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 %} + +



+ + + + + + + + + + + {% 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. From a3eaf101afe616524e1a52eba69596287943ae17 Mon Sep 17 00:00:00 2001 From: Eduardo Edson Batista Cordeiro Alves Date: Thu, 1 Sep 2016 16:45:33 -0300 Subject: [PATCH 5/7] =?UTF-8?q?Muda=20layout=20de=20acordo=20com=20o=20rel?= =?UTF-8?q?at=C3=B3rio?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../RelatorioMateriasPorTramitacao_filter.html | 14 +++++--------- 1 file changed, 5 insertions(+), 9 deletions(-) diff --git a/sapl/templates/base/RelatorioMateriasPorTramitacao_filter.html b/sapl/templates/base/RelatorioMateriasPorTramitacao_filter.html index 9e7b15771..134c3c20a 100644 --- a/sapl/templates/base/RelatorioMateriasPorTramitacao_filter.html +++ b/sapl/templates/base/RelatorioMateriasPorTramitacao_filter.html @@ -35,22 +35,18 @@ Matéria - Ementa - Autor(es) + Local Atual + Status {% for materia in object_list %} - {{materia.tipo.descricao}} - {{materia.tipo.sigla}} {{materia.numero}}/{{materia.ano}} + {{materia.tipo.descricao}} {{materia.numero}}/{{materia.ano}} - {{materia.ementa}} - - {% for autor in materia.autoria_set.all %} - {{autor.autor}}
- {% endfor %} - + {{materia.tramitacao_set.last.unidade_tramitacao_local}} + {{materia.tramitacao_set.last.status}} {% endfor %} From 461d20d49ade89f8cddbbf043ca91b15749bb02b Mon Sep 17 00:00:00 2001 From: Eduardo Edson Batista Cordeiro Alves Date: Thu, 1 Sep 2016 17:07:32 -0300 Subject: [PATCH 6/7] =?UTF-8?q?Filtra=20somente=20mat=C3=A9rias=20em=20tra?= =?UTF-8?q?mita=C3=A7=C3=A3o?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- sapl/base/forms.py | 1 - sapl/base/views.py | 6 +++++- 2 files changed, 5 insertions(+), 2 deletions(-) diff --git a/sapl/base/forms.py b/sapl/base/forms.py index d7f1f3a4c..4aa02c21b 100644 --- a/sapl/base/forms.py +++ b/sapl/base/forms.py @@ -48,7 +48,6 @@ class RelatorioMateriasTramitacaoilterSet(django_filters.FilterSet): fields = ['ano', 'tipo', 'tramitacao__unidade_tramitacao_local', 'tramitacao__status'] - def __init__(self, *args, **kwargs): super(RelatorioMateriasTramitacaoilterSet, self).__init__( *args, **kwargs) diff --git a/sapl/base/views.py b/sapl/base/views.py index 2f44fe039..db3ab016f 100644 --- a/sapl/base/views.py +++ b/sapl/base/views.py @@ -32,9 +32,13 @@ class RelatorioMateriasTramitacaoView(FilterView): context['title'] = _('Matérias por Ano, Autor e Tipo') + qs = context['object_list'] + qs = qs.filter(em_tramitacao=True) + context['object_list'] = qs + qtdes = {} for tipo in TipoMateriaLegislativa.objects.all(): - qs = kwargs['object_list'] + qs = context['object_list'] qtde = len(qs.filter(tipo_id=tipo.id)) if qtde > 0: qtdes[tipo] = qtde From 7c87db4f884fbf231124597db4733d7ceae03c2e Mon Sep 17 00:00:00 2001 From: Eduardo Edson Batista Cordeiro Alves Date: Fri, 2 Sep 2016 14:38:43 -0300 Subject: [PATCH 7/7] =?UTF-8?q?Adiciona=20relat=C3=B3rio=20de=20hist=C3=B3?= =?UTF-8?q?rico=20de=20tramita=C3=A7=C3=B5es?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- sapl/base/forms.py | 35 +++++++++++++++++++ sapl/base/urls.py | 5 +++ sapl/base/views.py | 16 ++++++++- .../RelatorioHistoricoTramitacao_filter.html | 34 ++++++++++++++++++ sapl/templates/base/relatorios_list.html | 2 +- 5 files changed, 90 insertions(+), 2 deletions(-) create mode 100644 sapl/templates/base/RelatorioHistoricoTramitacao_filter.html diff --git a/sapl/base/forms.py b/sapl/base/forms.py index 4aa02c21b..5af6ee179 100644 --- a/sapl/base/forms.py +++ b/sapl/base/forms.py @@ -37,6 +37,41 @@ class RangeWidgetOverride(forms.MultiWidget): return ''.join(rendered_widgets) +class RelatorioHistoricoTramitacaoFilterSet(django_filters.FilterSet): + + filter_overrides = {models.DateField: { + 'filter_class': django_filters.DateFromToRangeFilter, + 'extra': lambda f: { + 'label': '%s (%s)' % (f.verbose_name, _('Inicial - Final')), + 'widget': RangeWidgetOverride} + }} + + class Meta: + model = MateriaLegislativa + fields = ['tipo', 'tramitacao__unidade_tramitacao_local', + 'tramitacao__status', 'tramitacao__data_tramitacao'] + + def __init__(self, *args, **kwargs): + super(RelatorioHistoricoTramitacaoFilterSet, self).__init__( + *args, **kwargs) + + self.filters['tipo'].label = 'Tipo de Matéria' + + row1 = to_row([('tramitacao__data_tramitacao', 12)]) + row2 = to_row( + [('tipo', 4), + ('tramitacao__unidade_tramitacao_local', 4), + ('tramitacao__status', 4)]) + + self.form.helper = FormHelper() + self.form.helper.form_method = 'GET' + self.form.helper.layout = Layout( + Fieldset(_('Histórico de Tramita'), + row1, row2, + form_actions(save_label='Pesquisar')) + ) + + class RelatorioMateriasTramitacaoilterSet(django_filters.FilterSet): ano = django_filters.ChoiceFilter(required=True, diff --git a/sapl/base/urls.py b/sapl/base/urls.py index a59a1f924..b3dcac6ea 100644 --- a/sapl/base/urls.py +++ b/sapl/base/urls.py @@ -5,6 +5,7 @@ from django.views.generic.base import TemplateView from .apps import AppConfig from .forms import LoginForm from .views import (CasaLegislativaCrud, HelpView, + RelatorioHistoricoTramitacaoView, RelatorioMateriasPorAnoAutorTipoView, RelatorioMateriasPorAutorView, RelatorioMateriasTramitacaoView) @@ -35,4 +36,8 @@ urlpatterns = [ url(r'^relatorio/materia-por-tramitacao$', RelatorioMateriasTramitacaoView.as_view(), name='materia_por_tramitacao'), + url(r'^relatorio/historico-tramitacoes$', + RelatorioHistoricoTramitacaoView.as_view(), + name='historico_tramitacoes'), + ] diff --git a/sapl/base/views.py b/sapl/base/views.py index db3ab016f..ca5d735a3 100644 --- a/sapl/base/views.py +++ b/sapl/base/views.py @@ -10,7 +10,7 @@ from sapl.crud.base import (Crud, CrudBaseMixin, CrudCreateView, from sapl.materia.models import MateriaLegislativa, TipoMateriaLegislativa from sapl.utils import permissao_tb_aux -from .forms import (CasaLegislativaForm, +from .forms import (CasaLegislativaForm, RelatorioHistoricoTramitacaoFilterSet, RelatorioMateriasPorAnoAutorTipoFilterSet, RelatorioMateriasPorAutorFilterSet, RelatorioMateriasTramitacaoilterSet) @@ -21,6 +21,20 @@ def get_casalegislativa(): return CasaLegislativa.objects.first() +class RelatorioHistoricoTramitacaoView(FilterView): + model = MateriaLegislativa + filterset_class = RelatorioHistoricoTramitacaoFilterSet + template_name = 'base/RelatorioHistoricoTramitacao_filter.html' + + def get_context_data(self, **kwargs): + context = super(RelatorioHistoricoTramitacaoView, + self).get_context_data(**kwargs) + context['title'] = _('Histórico de Tramitações') + qr = self.request.GET.copy() + context['filter_url'] = ('&' + qr.urlencode()) if len(qr) > 0 else '' + return context + + class RelatorioMateriasTramitacaoView(FilterView): model = MateriaLegislativa filterset_class = RelatorioMateriasTramitacaoilterSet diff --git a/sapl/templates/base/RelatorioHistoricoTramitacao_filter.html b/sapl/templates/base/RelatorioHistoricoTramitacao_filter.html new file mode 100644 index 000000000..8cba5d186 --- /dev/null +++ b/sapl/templates/base/RelatorioHistoricoTramitacao_filter.html @@ -0,0 +1,34 @@ +{% extends "crud/list.html" %} +{% load i18n %} +{% load crispy_forms_tags %} + +{% block base_content %} + {% if not filter_url %} + {% crispy filter.form %} + {% endif %} + + {% if filter_url %} + +



+ + + + + + + + + {% for materia in object_list %} + + + + + {% endfor %} + +
MatériaEmenta
+ {{materia.tipo.descricao}} - {{materia.tipo.sigla}} {{materia.numero}}/{{materia.ano}} + {{materia.ementa}}
+ {% endif %} +{% endblock base_content %} diff --git a/sapl/templates/base/relatorios_list.html b/sapl/templates/base/relatorios_list.html index 44cefb933..49edf946c 100644 --- a/sapl/templates/base/relatorios_list.html +++ b/sapl/templates/base/relatorios_list.html @@ -33,7 +33,7 @@ Atas de Sessão Plenária. - Histórico de tramitações + Histórico de tramitações Histórico de tramitações por período e local informados.