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. 8
      sapl/norma/views.py
  7. 15
      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. 2
      sapl/templates/base/relatorios_list.html

3
sapl/base/forms.py

@ -1140,7 +1140,8 @@ class ConfiguracoesAppForm(ModelForm):
'cronometro_consideracoes', 'cronometro_consideracoes',
'mostrar_brasao_painel', 'mostrar_brasao_painel',
'receber_recibo_proposicao', 'receber_recibo_proposicao',
'assinatura_ata'] 'assinatura_ata',
'estatisticas_acesso_normas']
def __init__(self, *args, **kwargs): def __init__(self, *args, **kwargs):
super(ConfiguracoesAppForm, self).__init__(*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'), verbose_name=_('Relatórios de atos acessados'),
choices=RELATORIO_ATOS_ACESSADOS, default='N') 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( sequencia_numeracao = models.CharField(
max_length=1, max_length=1,
verbose_name=_('Sequência de numeração'), verbose_name=_('Sequência de numeração'),

7
sapl/base/urls.py

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

18
sapl/base/views.py

@ -280,6 +280,20 @@ class AutorCrud(CrudAux):
return url_reverse 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): class RelatorioAtasView(FilterView):
model = SessaoPlenaria model = SessaoPlenaria
filterset_class = RelatorioAtasFilterSet filterset_class = RelatorioAtasFilterSet
@ -874,12 +888,16 @@ class EstatisticasAcessoNormas(FilterView):
norma_est = [norma, len(NormaEstatisticas.objects.filter(norma=norma))] norma_est = [norma, len(NormaEstatisticas.objects.filter(norma=norma))]
normas_mes[meses[norma.data.month]].append(norma_est) normas_mes[meses[norma.data.month]].append(norma_est)
meses_sem_acesso = []
# Ordena por acesso e limita em 5 # Ordena por acesso e limita em 5
for n in normas_mes: for n in normas_mes:
sorted_by_value = sorted(normas_mes[n], key=lambda kv: kv[1], reverse=True) sorted_by_value = sorted(normas_mes[n], key=lambda kv: kv[1], reverse=True)
normas_mes[n] = sorted_by_value[0:5] 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['normas_mes'] = normas_mes
context['meses_sem_acesso'] = meses_sem_acesso
quant_normas_mes = {} quant_normas_mes = {}
for key in normas_mes.keys(): for key in normas_mes.keys():

8
sapl/norma/views.py

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

15
sapl/templates/base/EstatisticasAcessoNormas_filter.html

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

2
sapl/templates/base/RelatorioNormasVigencia_filter.html

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

6
sapl/templates/base/layouts.yaml

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

2
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><a href="{% url 'sapl.base:normas_por_vigencia' %}">Normas por vigência</a></td>
<td> Normas vigentes ou não vigentes. </td> <td> Normas vigentes ou não vigentes. </td>
</tr> </tr>
{% if estatisticas_acesso_normas %}
<tr> <tr>
<td><a href="{% url 'sapl.base:estatisticas_acesso' %}">Estatísticas de acesso de Normas.</a></td> <td><a href="{% url 'sapl.base:estatisticas_acesso' %}">Estatísticas de acesso de Normas.</a></td>
<td> Normas por acesso. </td> <td> Normas por acesso. </td>
</tr> </tr>
{% endif %}
</tbody> </tbody>
</table> </table>
</fieldset> </fieldset>

Loading…
Cancel
Save