diff --git a/sapl/base/forms.py b/sapl/base/forms.py index 8e5a345c0..540299fd2 100644 --- a/sapl/base/forms.py +++ b/sapl/base/forms.py @@ -875,6 +875,8 @@ class RelatorioNormasMesFilterSet(django_filters.FilterSet): class EstatisticasAcessoNormasForm(Form): + o = AnoNumeroOrderingFilter(help_text='') + ano = forms.ChoiceField(required=True, label='Ano de acesso', choices=RANGE_ANOS, @@ -889,11 +891,26 @@ class EstatisticasAcessoNormasForm(Form): row1 = to_row([('ano', 12)]) + buttons = FormActions( + *[ + HTML(''' +
+ + +
+ ''') + ], + Submit('pesquisar', _('Pesquisar'), css_class='float-right', + onclick='return true;'), + css_class='form-group row justify-content-between' + , + ) + self.helper = SaplFormHelper() self.helper.form_method = 'GET' self.helper.layout = Layout( Fieldset(_('Normas por acessos nos meses do ano.'), - row1, form_actions(label='Pesquisar')) + row1, buttons) ) def clean(self): diff --git a/sapl/base/views.py b/sapl/base/views.py index dbde3a2b1..c3c141335 100644 --- a/sapl/base/views.py +++ b/sapl/base/views.py @@ -34,7 +34,7 @@ from sapl.relatorios.views import (relatorio_materia_em_tramitacao, relatorio_ma relatorio_historico_tramitacao, relatorio_fim_prazo_tramitacao, relatorio_atas, relatorio_audiencia, relatorio_normas_mes, relatorio_normas_vigencia, relatorio_historico_tramitacao_adm, - relatorio_reuniao) + relatorio_reuniao, relatorio_estatisticas_acesso_normas) from sapl import settings from sapl.audiencia.models import AudienciaPublica, TipoAudienciaPublica @@ -1419,7 +1419,15 @@ class EstatisticasAcessoNormas(TemplateView): context['normas_mes'] = normas_mes - return self.render_to_response(context) + is_relatorio = request.GET.get('relatorio', None) + + context['show_results'] = show_results_filter_set( + self.request.GET.copy()) + + if is_relatorio: + return relatorio_estatisticas_acesso_normas(request, context) + else: + return self.render_to_response(context) class ListarInconsistenciasView(PermissionRequiredMixin, ListView): diff --git a/sapl/relatorios/views.py b/sapl/relatorios/views.py index ffd07d3d1..2505f4a15 100755 --- a/sapl/relatorios/views.py +++ b/sapl/relatorios/views.py @@ -1645,6 +1645,29 @@ def relatorio_historico_tramitacao_adm(request, context): return response +def relatorio_estatisticas_acesso_normas(request, context): + base_url = request.build_absolute_uri() + casa = CasaLegislativa.objects.first() + rodape = ' '.join(get_rodape(casa)) + + context.update({'data': dt.today().strftime('%d/%m/%Y')}) + context.update({'rodape': rodape}) + + header_context = {"casa": casa, 'logotipo': casa.logotipo, 'MEDIA_URL': MEDIA_URL} + + html_template = render_to_string('relatorios/relatorio_estatisticas_acesso_normas.html', context) + html_header = render_to_string('relatorios/header_ata.html', header_context) + + pdf_file = make_pdf(base_url=base_url, main_template=html_template, header_template=html_header) + + response = HttpResponse(content_type='application/pdf;') + response['Content-Disposition'] = 'inline; filename=relatorio.pdf' + response['Content-Transfer-Encoding'] = 'binary' + response.write(pdf_file) + + return response + + def relatorio_sessao_plenaria_pdf(request, pk): base_url=request.build_absolute_uri() logger = logging.getLogger(__name__) diff --git a/sapl/templates/relatorios/relatorio_estatisticas_acesso_normas.html b/sapl/templates/relatorios/relatorio_estatisticas_acesso_normas.html new file mode 100644 index 000000000..ac7602ac7 --- /dev/null +++ b/sapl/templates/relatorios/relatorio_estatisticas_acesso_normas.html @@ -0,0 +1,89 @@ +{% load i18n %} +{% load common_tags %} +{% load static %} + + + + + + + + +

Estatísticas de acesso de normas

+ + PARÂMETROS DE PESQUISA:
+  Ano: {{ ano }}
+
+ {% if normas_mes|length == 0 %} +
+

{% trans 'Nenhuma norma teve acesso neste ano.'%}

+ {% else %} + {% for mes, normas in normas_mes.items %} +
+ + + + + + +

Mês: {{ mes }}

+ + + + + + + + + + {% for n in normas %} + {% if n.1 > 0 %} + + + + + + {% endif %} + {% endfor %} + +
NormaEmentaAcessos
+ {{n.0.tipo.descricao}} - {{n.0.tipo.sigla}} {{n.0.numero}}/{{n.0.ano}} + {{n.0.ementa}}
{{n.0.observacao}}
{{n.1}}
+
+ {% endfor %} + {% endif %} + \ No newline at end of file