Browse Source

[WIP] Tela de controle de visibilidade de relatorio

tela-config-relatorio
Edward Ribeiro 1 year ago
parent
commit
97c10ec123
  1. 2
      sapl/relatorios/__init__.py
  2. 12
      sapl/relatorios/forms.py
  3. 29
      sapl/relatorios/migrations/0001_initial.py
  4. 0
      sapl/relatorios/migrations/__init__.py
  5. 25
      sapl/relatorios/models.py
  6. 7
      sapl/relatorios/urls.py
  7. 20
      sapl/relatorios/views.py
  8. 1
      sapl/settings.py
  9. 3
      sapl/templates/menu_tabelas_auxiliares.yaml
  10. 9
      sapl/templates/relatorios/configuracao.html
  11. 4
      sapl/templates/sistema.html

2
sapl/relatorios/__init__.py

@ -1 +1 @@
default_app_config = 'relatorios.apps.AppConfig' default_app_config = 'sapl.relatorios.apps.AppConfig'

12
sapl/relatorios/forms.py

@ -309,7 +309,8 @@ class RelatorioDataFimPrazoTramitacaoFilterSet(django_filters.FilterSet):
@property @property
def qs(self): def qs(self):
parent = super(RelatorioDataFimPrazoTramitacaoFilterSet, self).qs parent = super(RelatorioDataFimPrazoTramitacaoFilterSet, self).qs
return parent.distinct().prefetch_related('materia__tipo').order_by('tramitacao__data_fim_prazo', 'materia__tipo', 'materia__numero') return parent.distinct().prefetch_related('materia__tipo').order_by('tramitacao__data_fim_prazo',
'materia__tipo', 'materia__numero')
class Meta(FilterOverridesMetaMixin): class Meta(FilterOverridesMetaMixin):
model = MateriaEmTramitacao model = MateriaEmTramitacao
@ -774,3 +775,12 @@ class RelatorioNormasVigenciaFilterSet(django_filters.FilterSet):
@property @property
def qs(self): def qs(self):
return qs_override_django_filter(self) return qs_override_django_filter(self)
class ConfiguracaoRelatorioForm(forms.Form):
nome = forms.CharField(required=True,
label="Nome",
max_length=100)
url = forms.CharField(required=True,
label="URL",
max_length=200)

29
sapl/relatorios/migrations/0001_initial.py

@ -0,0 +1,29 @@
# Generated by Django 2.2.28 on 2023-07-25 00:53
from django.db import migrations, models
class Migration(migrations.Migration):
initial = True
dependencies = [
]
operations = [
migrations.CreateModel(
name='RelatorioConfig',
fields=[
('id', models.AutoField(auto_created=True, primary_key=True, serialize=False, verbose_name='ID')),
('nome', models.CharField(max_length=100, verbose_name='Nome')),
('url', models.CharField(max_length=200, verbose_name='URL')),
('publico', models.BooleanField(choices=[(True, 'Sim'), (False, 'Não')], db_index=True, default=True, verbose_name='Público')),
('privado', models.BooleanField(choices=[(True, 'Sim'), (False, 'Não')], db_index=True, default=True, verbose_name='Público')),
],
options={
'verbose_name': 'Configuração de Relatório',
'verbose_name_plural': 'Configurações de Relatórios',
'ordering': ['nome'],
},
),
]

0
sapl/relatorios/migrations/__init__.py

25
sapl/relatorios/models.py

@ -1,3 +1,24 @@
# from django.db import models from django.db import models
from django.utils.translation import ugettext_lazy as _
from sapl.utils import YES_NO_CHOICES
# Create your models here.
class RelatorioConfig(models.Model):
nome = models.CharField(max_length=100, verbose_name=_('Nome'))
url = models.CharField(max_length=200, verbose_name=_('URL'))
publico = models.BooleanField(db_index=True,
default=True,
choices=YES_NO_CHOICES,
verbose_name=_('Público'))
privado = models.BooleanField(db_index=True,
default=True,
choices=YES_NO_CHOICES,
verbose_name=_('Público'))
class Meta:
verbose_name = _('Configuração de Relatório')
verbose_name_plural = _('Configurações de Relatórios')
ordering = ['nome']
def __str__(self):
return f"{self.nome} - {self.url}"

7
sapl/relatorios/urls.py

@ -1,4 +1,4 @@
from django.conf.urls import url from django.conf.urls import include, url
from .apps import AppConfig from .apps import AppConfig
from .views import (relatorio_capa_processo, from .views import (relatorio_capa_processo,
@ -11,7 +11,7 @@ from .views import (relatorio_capa_processo,
RelatorioMateriasTramitacaoView, RelatorioMateriaAnoAssuntoView, RelatorioHistoricoTramitacaoView, RelatorioMateriasTramitacaoView, RelatorioMateriaAnoAssuntoView, RelatorioHistoricoTramitacaoView,
RelatorioDataFimPrazoTramitacaoView, RelatorioPresencaSessaoView, RelatorioAtasView, RelatorioDataFimPrazoTramitacaoView, RelatorioPresencaSessaoView, RelatorioAtasView,
RelatorioReuniaoView, RelatorioAudienciaView, RelatorioHistoricoTramitacaoAdmView, RelatorioReuniaoView, RelatorioAudienciaView, RelatorioHistoricoTramitacaoAdmView,
RelatorioDocumentosAcessoriosView, RelatorioNormasPorAutorView) RelatorioDocumentosAcessoriosView, RelatorioNormasPorAutorView, RelatorioConfigView)
from ..base.views import EstatisticasAcessoNormas from ..base.views import EstatisticasAcessoNormas
app_name = AppConfig.name app_name = AppConfig.name
@ -51,7 +51,8 @@ urlpatterns = [
url(r'^relatorios/(?P<pk>\d+)/materia-tramitacao$', url(r'^relatorios/(?P<pk>\d+)/materia-tramitacao$',
relatorio_materia_tramitacao, name='relatorio_materia_tramitacao'), relatorio_materia_tramitacao, name='relatorio_materia_tramitacao'),
# TODO mover estas telas para a app 'relatorios' url(r'^sistema/relatorios/configuracao/',
RelatorioConfigView.as_view(), name='relatorio_config'),
url(r'^sistema/relatorios/$', url(r'^sistema/relatorios/$',
RelatoriosListView.as_view(), name='relatorios_list'), RelatoriosListView.as_view(), name='relatorios_list'),
url(r'^sistema/relatorios/materia-por-autor$', url(r'^sistema/relatorios/materia-por-autor$',

20
sapl/relatorios/views.py

@ -5,13 +5,16 @@ import re
from datetime import datetime as dt, datetime from datetime import datetime as dt, datetime
import unidecode import unidecode
from django.contrib.auth.mixins import PermissionRequiredMixin
from django.views.generic.detail import DetailView
from django.views.generic.edit import FormMixin
from django.core.exceptions import ObjectDoesNotExist from django.core.exceptions import ObjectDoesNotExist
from django.db.models import Count, Q, F from django.db.models import Count, Q, F
from django.http import Http404, HttpResponse from django.http import Http404, HttpResponse
from django.template.loader import render_to_string from django.template.loader import render_to_string
from django.utils import timezone from django.utils import timezone
from django.utils.translation import ugettext_lazy as _ from django.utils.translation import ugettext_lazy as _
from django.views.generic import TemplateView, ListView from django.views.generic import TemplateView, ListView, FormView
from django_filters.views import FilterView from django_filters.views import FilterView
from weasyprint import HTML, CSS from weasyprint import HTML, CSS
@ -31,7 +34,8 @@ from sapl.relatorios.forms import RelatorioNormasPorAutorFilterSet, RelatorioHis
RelatorioNormasVigenciaFilterSet, RelatorioNormasMesFilterSet, RelatorioMateriasPorAutorFilterSet, \ RelatorioNormasVigenciaFilterSet, RelatorioNormasMesFilterSet, RelatorioMateriasPorAutorFilterSet, \
RelatorioMateriasPorAnoAutorTipoFilterSet, RelatorioMateriasTramitacaoFilterSet, RelatorioAudienciaFilterSet, \ RelatorioMateriasPorAnoAutorTipoFilterSet, RelatorioMateriasTramitacaoFilterSet, RelatorioAudienciaFilterSet, \
RelatorioReuniaoFilterSet, RelatorioDataFimPrazoTramitacaoFilterSet, RelatorioHistoricoTramitacaoFilterSet, \ RelatorioReuniaoFilterSet, RelatorioDataFimPrazoTramitacaoFilterSet, RelatorioHistoricoTramitacaoFilterSet, \
RelatorioPresencaSessaoFilterSet, RelatorioAtasFilterSet, RelatorioDocumentosAcessoriosFilterSet RelatorioPresencaSessaoFilterSet, RelatorioAtasFilterSet, RelatorioDocumentosAcessoriosFilterSet, \
ConfiguracaoRelatorioForm
from sapl.sessao.models import (ExpedienteMateria, ExpedienteSessao, from sapl.sessao.models import (ExpedienteMateria, ExpedienteSessao,
IntegranteMesa, JustificativaAusencia, IntegranteMesa, JustificativaAusencia,
Orador, OradorExpediente, Orador, OradorExpediente,
@ -51,12 +55,14 @@ from sapl.settings import MEDIA_URL
from sapl.settings import STATIC_ROOT from sapl.settings import STATIC_ROOT
from sapl.utils import LISTA_DE_UFS, TrocaTag, filiacao_data, create_barcode, show_results_filter_set, \ from sapl.utils import LISTA_DE_UFS, TrocaTag, filiacao_data, create_barcode, show_results_filter_set, \
num_materias_por_tipo, parlamentares_ativos num_materias_por_tipo, parlamentares_ativos
from .models import RelatorioConfig
from .templates import (pdf_capa_processo_gerar, from .templates import (pdf_capa_processo_gerar,
pdf_documento_administrativo_gerar, pdf_espelho_gerar, pdf_documento_administrativo_gerar, pdf_espelho_gerar,
pdf_etiqueta_protocolo_gerar, pdf_materia_gerar, pdf_etiqueta_protocolo_gerar, pdf_materia_gerar,
pdf_ordem_dia_gerar, pdf_pauta_sessao_gerar, pdf_ordem_dia_gerar, pdf_pauta_sessao_gerar,
pdf_protocolo_gerar, pdf_sessao_plenaria_gerar) pdf_protocolo_gerar, pdf_sessao_plenaria_gerar)
from sapl.crud.base import make_pagination from sapl.crud.base import make_pagination, Crud
from ..rules import RP_LIST, RP_DETAIL
def get_kwargs_params(request, fields): def get_kwargs_params(request, fields):
@ -2727,3 +2733,11 @@ class RelatorioNormasPorAutorView(RelatorioMixin, FilterView):
' - ' + self.request.GET['data_1']) ' - ' + self.request.GET['data_1'])
return context return context
class RelatorioConfigView(FormMixin, DetailView):
form_class = ConfiguracaoRelatorioForm
template_name = 'relatorios/configuracao.html'
permission_required = ('base.list_appconfig',)
logger = logging.getLogger(__name__)

1
sapl/settings.py

@ -63,6 +63,7 @@ SAPL_APPS = (
'sapl.protocoloadm', 'sapl.protocoloadm',
'sapl.compilacao', 'sapl.compilacao',
'sapl.api', 'sapl.api',
'sapl.relatorios',
'sapl.rules' 'sapl.rules'
) )

3
sapl/templates/menu_tabelas_auxiliares.yaml

@ -14,6 +14,9 @@
- title: {% trans 'Autores' %} - title: {% trans 'Autores' %}
url: sapl.base:autor_list url: sapl.base:autor_list
css_class: btn btn-link css_class: btn btn-link
- title: {% trans 'Configuração de Relatórios' %}
url: sapl.relatorios:relatorio_config
css_class: btn btn-link
{% if not sapl_as_sapn%} {% if not sapl_as_sapn%}
- title: {% trans 'Módulo Parlamentares' %} - title: {% trans 'Módulo Parlamentares' %}
css_class: head_title css_class: head_title

9
sapl/templates/relatorios/configuracao.html

@ -0,0 +1,9 @@
{% extends "crud/detail.html" %}
{% load i18n %}
{% load common_tags %}
{% block actions %}{% endblock %}
{% block detail_content %}
Teste
{% endblock detail_content %}

4
sapl/templates/sistema.html

@ -83,8 +83,8 @@
<div class="col-md-6"><a href="{% url 'sapl.norma:assuntonorma_list' %}" class="btn btn-link">Assunto de Norma Jurídica</a></div> <div class="col-md-6"><a href="{% url 'sapl.norma:assuntonorma_list' %}" class="btn btn-link">Assunto de Norma Jurídica</a></div>
<div class="col-md-6"><a href="{% url 'sapl.norma:tipovinculonormajuridica_list' %}" class="btn btn-link">Tipo de Vínculo</a></div> <div class="col-md-6"><a href="{% url 'sapl.norma:tipovinculonormajuridica_list' %}" class="btn btn-link">Tipo de Vínculo</a></div>
</div> </div>
<hr /> <hr />
<h2>Módulo Textos Articulados</h2> <h2>Módulo Textos Articulados</h2>
<div class="row"> <div class="row">
<div class="col-md-6"><a class="btn btn-link" href="{% url 'sapl.compilacao:tipotextoarticulado_list' %}">Tipos de Textos Articulados</a></div> <div class="col-md-6"><a class="btn btn-link" href="{% url 'sapl.compilacao:tipotextoarticulado_list' %}">Tipos de Textos Articulados</a></div>
@ -95,8 +95,6 @@
<div class="col-md-6"><a class="btn btn-link" href="{% url 'sapl.compilacao:tipodispositivo_list' %}">Tipos de Dispositivos</a></div> <div class="col-md-6"><a class="btn btn-link" href="{% url 'sapl.compilacao:tipodispositivo_list' %}">Tipos de Dispositivos</a></div>
<div class="col-md-6"><a class="btn btn-link" href="/admin/compilacao/tipodispositivorelationship/">Relacionamento entre Dispositivos</a></div> <div class="col-md-6"><a class="btn btn-link" href="/admin/compilacao/tipodispositivorelationship/">Relacionamento entre Dispositivos</a></div>
</div> </div>
<hr /> <hr />
<h2>Módulo Sessão Plenária</h2> <h2>Módulo Sessão Plenária</h2>

Loading…
Cancel
Save