Browse Source

correcoes e adicao de opcao no configuracao de aplicacao

pull/2429/head
Cesar Carvalho 7 years ago
parent
commit
7e1554a03e
  1. 3
      sapl/base/forms.py
  2. 20
      sapl/base/migrations/0028_appconfig_estatisticas_acesso_normas.py
  3. 5
      sapl/base/models.py
  4. 7
      sapl/base/urls.py
  5. 18
      sapl/base/views.py
  6. 12
      sapl/norma/views.py
  7. 71
      sapl/templates/base/EstatisticasAcessoNormas_filter.html
  8. 2
      sapl/templates/base/RelatorioNormaMes_filter.html
  9. 2
      sapl/templates/base/RelatorioNormasVigencia_filter.html
  10. 6
      sapl/templates/base/layouts.yaml
  11. 10
      sapl/templates/base/relatorios_list.html

3
sapl/base/forms.py

@ -1140,7 +1140,8 @@ class ConfiguracoesAppForm(ModelForm):
'cronometro_consideracoes',
'mostrar_brasao_painel',
'receber_recibo_proposicao',
'assinatura_ata']
'assinatura_ata',
'estatisticas_acesso_normas']
def __init__(self, *args, **kwargs):
super(ConfiguracoesAppForm, self).__init__(*args, **kwargs)

20
sapl/base/migrations/0028_appconfig_estatisticas_acesso_normas.py

@ -0,0 +1,20 @@
# -*- coding: utf-8 -*-
# Generated by Django 1.10.8 on 2018-12-18 17:03
from __future__ import unicode_literals
from django.db import migrations, models
class Migration(migrations.Migration):
dependencies = [
('base', '0027_appconfig_relatorios_atos'),
]
operations = [
migrations.AddField(
model_name='appconfig',
name='estatisticas_acesso_normas',
field=models.CharField(choices=[('S', 'Sim'), ('N', 'Não')], default='N', max_length=1, verbose_name='Estatísticas de acesso a normas'),
),
]

5
sapl/base/models.py

@ -92,6 +92,11 @@ class AppConfig(models.Model):
verbose_name=_('Relatórios de atos acessados'),
choices=RELATORIO_ATOS_ACESSADOS, default='N')
estatisticas_acesso_normas = models.CharField(
max_length=1,
verbose_name=_('Estatísticas de acesso a normas'),
choices=RELATORIO_ATOS_ACESSADOS, default='N')
sequencia_numeracao = models.CharField(
max_length=1,
verbose_name=_('Sequência de numeração'),

7
sapl/base/urls.py

@ -26,7 +26,8 @@ from .views import (AlterarSenha, AppConfigCrud, CasaLegislativaCrud,
RelatorioReuniaoView, SaplSearchView,
RelatorioNormasPublicadasMesView,
RelatorioNormasVigenciaView,
EstatisticasAcessoNormas)
EstatisticasAcessoNormas,
RelatoriosListView)
app_name = AppConfig.name
@ -87,8 +88,8 @@ urlpatterns = [
url(r'^sistema/app-config/', include(AppConfigCrud.get_urls())),
# TODO mover estas telas para a app 'relatorios'
url(r'^sistema/relatorios/$', TemplateView.as_view(
template_name='base/relatorios_list.html'), name='relatorios_list'),
url(r'^sistema/relatorios/$',
RelatoriosListView.as_view(), name='relatorios_list'),
url(r'^sistema/relatorios/materia-por-autor$',
RelatorioMateriasPorAutorView.as_view(), name='materia_por_autor'),
url(r'^sistema/relatorios/relatorio-por-mes$',

18
sapl/base/views.py

@ -280,6 +280,20 @@ class AutorCrud(CrudAux):
return url_reverse
class RelatoriosListView(TemplateView):
template_name='base/relatorios_list.html'
def get_context_data(self, **kwargs):
context = super(TemplateView, self).get_context_data(**kwargs)
estatisticas_acesso_normas = AppConfig.objects.first().estatisticas_acesso_normas
if estatisticas_acesso_normas == 'S':
context['estatisticas_acesso_normas'] = True
else:
context['estatisticas_acesso_normas'] = False
return context
class RelatorioAtasView(FilterView):
model = SessaoPlenaria
filterset_class = RelatorioAtasFilterSet
@ -874,12 +888,16 @@ class EstatisticasAcessoNormas(FilterView):
norma_est = [norma, len(NormaEstatisticas.objects.filter(norma=norma))]
normas_mes[meses[norma.data.month]].append(norma_est)
meses_sem_acesso = []
# Ordena por acesso e limita em 5
for n in normas_mes:
sorted_by_value = sorted(normas_mes[n], key=lambda kv: kv[1], reverse=True)
normas_mes[n] = sorted_by_value[0:5]
if all(v[1]==0 for v in normas_mes[n]):
meses_sem_acesso.append(n)
context['normas_mes'] = normas_mes
context['meses_sem_acesso'] = meses_sem_acesso
quant_normas_mes = {}
for key in normas_mes.keys():

12
sapl/norma/views.py

@ -1,6 +1,8 @@
import re
import logging
import re
import sapl
import weasyprint
from django.contrib.auth.mixins import PermissionRequiredMixin
from django.core.exceptions import ObjectDoesNotExist
@ -13,8 +15,6 @@ from django.views.generic import TemplateView, UpdateView
from django.views.generic.base import RedirectView
from django.views.generic.edit import FormView
from django_filters.views import FilterView
import weasyprint
import sapl
from sapl.base.models import AppConfig
from sapl.compilacao.views import IntegracaoTaView
from sapl.crud.base import (RP_DETAIL, RP_LIST, Crud, CrudAux,
@ -191,8 +191,10 @@ class NormaCrud(Crud):
class DetailView(Crud.DetailView):
def get(self, request, *args, **kwargs):
NormaEstatisticas.objects.create(usuario=str(self.request.user),
norma_id=kwargs['pk'])
estatisticas_acesso_normas = AppConfig.objects.first().estatisticas_acesso_normas
if estatisticas_acesso_normas == 'S':
NormaEstatisticas.objects.create(usuario=str(self.request.user),
norma_id=kwargs['pk'])
return super().get(request, *args, **kwargs)

71
sapl/templates/base/EstatisticasAcessoNormas_filter.html

@ -17,37 +17,48 @@
{% if normas_mes|length == 0 %}
<br>
<h3>{% trans 'Não foi encontrada nenhuma norma com os parâmetros buscados.'%}</h3>
{% endif %}
{% for mes, normas in normas_mes.items %}
<div style="overflow:auto; ">
<table class="table table-bordered table-hover" style="margin-bottom: 0px;">
<thead class="thead-default">
<tr>
<th><h3 style="text-align:center;">Mês: {{ mes }}</h3></th>
</tr>
</thead>
</table>
<table class="table table-bordered table-hover" style="width:100%; margin-bottom: 30px;">
<thead class="thead-default" >
<tr class="active">
<th>Matéria</th>
<th>Norma</th>
<th>Acessos</th>
</tr>
</thead>
<tbody>
{% for n in normas %}
{% elif normas_mes|length == meses_sem_acesso|length %}
<br>
<h3>{% trans 'Nenhuma norma teve acesso neste ano.'%}</h3>
{% else %}
{% for mes, normas in normas_mes.items %}
<div style="overflow:auto; ">
<table class="table table-bordered table-hover" style="margin-bottom: 0px;">
<thead class="thead-default">
<tr>
<td><a href="{% url 'sapl.norma:normajuridica_detail' n.0.pk %}">
{{n.0.tipo.descricao}} - {{n.0.tipo.sigla}} {{n.0.numero}}/{{n.0.ano}}
</a></td>
<td>{{n.0.ementa}}<br>{{n.0.observacao}}</td>
<td>{{n.1}}</td>
<th><h3 style="text-align:center;">Mês: {{ mes }}</h3></th>
</tr>
{% endfor %}
</tbody>
</table>
</div>
{% endfor %}
</thead>
</table>
{% if not mes in meses_sem_acesso %}
<table class="table table-bordered table-hover" style="width:100%; margin-bottom: 30px;">
<thead class="thead-default" >
<tr class="active">
<th>Norma</th>
<th>Ementa</th>
<th>Acessos</th>
</tr>
</thead>
<tbody>
{% for n in normas %}
{% if n.1 > 0 %}
<tr>
<td><a href="{% url 'sapl.norma:normajuridica_detail' n.0.pk %}">
{{n.0.tipo.descricao}} - {{n.0.tipo.sigla}} {{n.0.numero}}/{{n.0.ano}}
</a></td>
<td>{{n.0.ementa}}<br>{{n.0.observacao}}</td>
<td>{{n.1}}</td>
</tr>
{% endif %}
{% endfor %}
</tbody>
</table>
{% else %}
<h3 style="text-align:center;">{% trans 'Nenhuma norma deste mês teve acessos.'%}</h3>
<br><br>
{% endif %}
</div>
{% endfor %}
{% endif %}
{% endif %}
{% endblock base_content %}

2
sapl/templates/base/RelatorioNormaMes_filter.html

@ -46,8 +46,8 @@
<table class="table table-bordered table-hover" style="width:100%; margin-bottom: 30px;">
<thead class="thead-default" >
<tr class="active">
<th>Matéria</th>
<th>Norma</th>
<th>Ementa</th>
</tr>
</thead>
<tbody>

2
sapl/templates/base/RelatorioNormasVigencia_filter.html

@ -26,8 +26,8 @@
<table class="table table-bordered table-hover" style="width:100%">
<thead class="thead-default" >
<tr class="active">
<th>Matéria</th>
<th>Norma</th>
<th>Ementa</th>
</tr>
</thead>
<tbody>

6
sapl/templates/base/layouts.yaml

@ -23,6 +23,12 @@ AppConfig:
{% trans 'Textos Articulados' %}:
- texto_articulado_proposicao texto_articulado_materia texto_articulado_norma
{% trans 'Relatórios' %}:
- relatorios_atos
{% trans 'Estatísticas de acesso' %}:
- estatisticas_acesso_normas
{% trans 'Assinaturas' %}:
- assinatura_ata

10
sapl/templates/base/relatorios_list.html

@ -56,10 +56,12 @@
<td><a href="{% url 'sapl.base:normas_por_vigencia' %}">Normas por vigência</a></td>
<td> Normas vigentes ou não vigentes. </td>
</tr>
<tr>
<td><a href="{% url 'sapl.base:estatisticas_acesso' %}">Estatísticas de acesso de Normas.</a></td>
<td> Normas por acesso. </td>
</tr>
{% if estatisticas_acesso_normas %}
<tr>
<td><a href="{% url 'sapl.base:estatisticas_acesso' %}">Estatísticas de acesso de Normas.</a></td>
<td> Normas por acesso. </td>
</tr>
{% endif %}
</tbody>
</table>
</fieldset>

Loading…
Cancel
Save