Browse Source

geracao de pdf para Norma por Autor

pull/2895/head
ricardocanela 6 years ago
parent
commit
4bf67c18c8
  1. 18
      sapl/base/forms.py
  2. 18
      sapl/base/views.py
  3. 3
      sapl/relatorios/views.py
  4. 106
      sapl/templates/relatorios/relatorio_normas_por_autor.html

18
sapl/base/forms.py

@ -1759,6 +1759,20 @@ class RelatorioNormasPorAutorFilterSet(django_filters.FilterSet):
(Button('limpar',
'Limpar Autor',
css_class='btn btn-primary btn-sm'), 10)])
buttons = FormActions(
*[
HTML('''
<div class="form-check">
<input name="relatorio" type="checkbox" class="form-check-input" id="relatorio">
<label class="form-check-label" for="relatorio">Gerar relatório PDF</label>
</div>
''')
],
Submit('pesquisar', _('Pesquisar'), css_class='float-right',
onclick='return true;'),
css_class='form-group row justify-content-between'
,
)
self.form.helper = SaplFormHelper()
self.form.helper.form_method = 'GET'
@ -1768,5 +1782,5 @@ class RelatorioNormasPorAutorFilterSet(django_filters.FilterSet):
HTML(autor_label),
HTML(autor_modal),
row3,
form_actions(label='Pesquisar'))
)
buttons)
)

18
sapl/base/views.py

@ -34,7 +34,8 @@ 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_estatisticas_acesso_normas)
relatorio_reuniao, relatorio_estatisticas_acesso_normas,
relatorio_normas_por_autor)
from sapl import settings
from sapl.audiencia.models import AudienciaPublica, TipoAudienciaPublica
@ -2120,10 +2121,11 @@ class RelatorioHistoricoTramitacaoAdmView(RelatorioMixin, FilterView):
return context
class RelatorioNormasPorAutorView(FilterView):
class RelatorioNormasPorAutorView(RelatorioMixin, FilterView):
model = NormaJuridica
filterset_class = RelatorioNormasPorAutorFilterSet
template_name = 'base/RelatorioNormasPorAutor_filter.html'
relatorio = relatorio_normas_por_autor
def get_filterset_kwargs(self, filterset_class):
super().get_filterset_kwargs(filterset_class)
@ -2139,7 +2141,7 @@ class RelatorioNormasPorAutorView(FilterView):
qtdes = {}
for tipo in TipoNormaJuridica.objects.all():
qs = kwargs['object_list']
qs = context['object_list']
qtde = len(qs.filter(tipo_id=tipo.id))
if qtde > 0:
qtdes[tipo] = qtde
@ -2166,13 +2168,3 @@ class RelatorioNormasPorAutorView(FilterView):
' - ' + self.request.GET['data_1'])
return context
def get(self, request, *args, **kwargs):
super(RelatorioHistoricoTramitacaoAdmView, self).get(request)
is_relatorio = request.GET.get('relatorio', None)
context = self.get_context_data(filter=self.filterset)
if is_relatorio:
return relatorio_historico_tramitacao_adm(request, context)
else:
return self.render_to_response(context)

3
sapl/relatorios/views.py

@ -1408,6 +1408,9 @@ def relatorio_historico_tramitacao_adm(obj, request, context):
def relatorio_estatisticas_acesso_normas(obj, request, context):
return cria_relatorio(request, context, 'relatorios/relatorio_estatisticas_acesso_normas.html')
def relatorio_normas_por_autor(obj, request, context):
return cria_relatorio(request, context, 'relatorios/relatorio_normas_por_autor.html')
def relatorio_sessao_plenaria_pdf(request, pk):
base_url=request.build_absolute_uri()
logger = logging.getLogger(__name__)

106
sapl/templates/relatorios/relatorio_normas_por_autor.html

@ -0,0 +1,106 @@
{% load i18n %}
{% load common_tags %}
{% load static %}
<head>
<style>
@page{
margin-top: 4.5cm;
size: A4 portrait;
@bottom-right {
content: "Página" counter(page);
height: 3cm;
font-size: 8pt;
}
@bottom-center {
border-top: 1px solid black;
font-size: 8pt;
height: 1cm;
content: "{{rodape|safe}}";
font-style:italic;
}
@bottom-left {
content: "{{data}}";
height: 3cm;
font-size: 8pt;
}
@top-center {
content: string(title);
}
header {
width: 0;
height: 0;
visibility: hidden;
string-set: title content();
}
}
</style>
<link rel="stylesheet" href="{% static '/sapl/css/relatorio.css'%}">
</head>
<h2>Matérias por Autor</h2>
<b>PARÂMETROS DE PESQUISA:<br /></b>
&emsp;Autor: {{ autor }}<br />
&emsp;Tipo de Norma: {{ tipo }}<br />
&emsp;Data: {{periodo}}<br /><br /><br/>
{% if object_list %}
<table class="table table-bordered table-hover">
<thead class="thead-default" >
<tr class="active"><th colspan="3" class="text-center">QUADRO GERAL</th></tr>
<tr class="active">
<th colspan="2">Tipo de Norma</th>
<th>Quantidade</th>
</tr>
</thead>
<tbody>
{% for key, value in qtdes.items %}
<tr>
<td colspan="2">{{key.sigla}} - {{key}}</td>
<td>{{value}}</td>
</tr>
{% endfor %}
</tbody>
{% for norma in object_list %}
{% ifchanged norma.autorianorma_set.first.autor %}
<thead class="thead-default" >
<tr style="border-left: hidden; border-right: hidden;"><th colspan="3"></th></tr>
<tr class="active"><th colspan="3" class="text-center">Autor: {{ norma.autorianorma_set.first.autor }}</th></tr>
<tr class="active">
<th width="10%">Norma</th>
<th>Ementa</th>
<th width="20%">Coautor(es)</th>
</tr>
</thead>
{% endifchanged %}
<tbody>
<tr>
<td>
{{norma.tipo.sigla}} {{norma.numero}}/{{norma.ano}}
</td>
<td>{% autoescape off %}{{norma.ementa}}<br>{{norma.observacao}}{% endautoescape %}</td>
<td>
{% if norma.autorianorma_set.first != norma.autorianorma_set.last %}
{% for autor in norma.autorianorma_set.all %}
{% if not autor.primeiro_autor %}
{{ autor.autor }}<br />
{% endif %}
{% endfor %}
{% endif %}
</td>
</tr>
</tbody>
{% endfor %}
</table>
{% else %}
<h3>Não foram encontradas normas com os parâmetros pesquisados.</h3>
{% endif %}
</body>
Loading…
Cancel
Save