Browse Source

Faz o merge com o master

pull/540/head
Eduardo Calil 8 years ago
parent
commit
f075944f5b
  1. 168
      sapl/base/forms.py
  2. 20
      sapl/base/urls.py
  3. 115
      sapl/base/views.py
  4. 5
      sapl/materia/views.py
  5. 10
      sapl/parlamentares/urls.py
  6. 92
      sapl/parlamentares/views.py
  7. 16
      sapl/sessao/views.py
  8. 4
      sapl/templates/base.html
  9. 34
      sapl/templates/base/RelatorioHistoricoTramitacao_filter.html
  10. 60
      sapl/templates/base/RelatorioMateriasPorAnoAutorTipo_filter.html
  11. 60
      sapl/templates/base/RelatorioMateriasPorAutor_filter.html
  12. 56
      sapl/templates/base/RelatorioMateriasPorTramitacao_filter.html
  13. 18
      sapl/templates/base/relatorios_list.html
  14. 6
      sapl/templates/parlamentares/subnav.yaml
  15. 2
      sapl/templates/sessao/presenca.html
  16. 2
      sapl/templates/sessao/presenca_ordemdia.html
  17. 106
      sapl/utils.py

168
sapl/base/forms.py

@ -1,14 +1,180 @@
import django_filters
from crispy_forms.helper import FormHelper
from crispy_forms.layout import HTML, Button, Fieldset, Layout
from django import forms from django import forms
from django.contrib.auth.forms import AuthenticationForm from django.contrib.auth.forms import AuthenticationForm
from django.core.exceptions import ValidationError from django.core.exceptions import ValidationError
from django.db import models
from django.forms import ModelForm from django.forms import ModelForm
from django.utils.translation import ugettext_lazy as _
from sapl.crispy_layout_mixin import form_actions, to_row
from sapl.materia.models import MateriaLegislativa
from sapl.settings import MAX_IMAGE_UPLOAD_SIZE from sapl.settings import MAX_IMAGE_UPLOAD_SIZE
from sapl.utils import ImageThumbnailFileInput from sapl.utils import (RANGE_ANOS, ImageThumbnailFileInput, autor_label,
autor_modal)
from .models import CasaLegislativa from .models import CasaLegislativa
class RangeWidgetOverride(forms.MultiWidget):
def __init__(self, attrs=None):
widgets = (forms.DateInput(format='%d/%m/%Y',
attrs={'class': 'dateinput',
'placeholder': 'Inicial'}),
forms.DateInput(format='%d/%m/%Y',
attrs={'class': 'dateinput',
'placeholder': 'Final'}))
super(RangeWidgetOverride, self).__init__(widgets, attrs)
def decompress(self, value):
if value:
return [value.start, value.stop]
return [None, None]
def format_output(self, rendered_widgets):
return ''.join(rendered_widgets)
class RelatorioHistoricoTramitacaoFilterSet(django_filters.FilterSet):
filter_overrides = {models.DateField: {
'filter_class': django_filters.DateFromToRangeFilter,
'extra': lambda f: {
'label': '%s (%s)' % (f.verbose_name, _('Inicial - Final')),
'widget': RangeWidgetOverride}
}}
class Meta:
model = MateriaLegislativa
fields = ['tipo', 'tramitacao__unidade_tramitacao_local',
'tramitacao__status', 'tramitacao__data_tramitacao']
def __init__(self, *args, **kwargs):
super(RelatorioHistoricoTramitacaoFilterSet, self).__init__(
*args, **kwargs)
self.filters['tipo'].label = 'Tipo de Matéria'
row1 = to_row([('tramitacao__data_tramitacao', 12)])
row2 = to_row(
[('tipo', 4),
('tramitacao__unidade_tramitacao_local', 4),
('tramitacao__status', 4)])
self.form.helper = FormHelper()
self.form.helper.form_method = 'GET'
self.form.helper.layout = Layout(
Fieldset(_('Histórico de Tramita'),
row1, row2,
form_actions(save_label='Pesquisar'))
)
class RelatorioMateriasTramitacaoilterSet(django_filters.FilterSet):
ano = django_filters.ChoiceFilter(required=True,
label=u'Ano da Matéria',
choices=RANGE_ANOS)
class Meta:
model = MateriaLegislativa
fields = ['ano', 'tipo', 'tramitacao__unidade_tramitacao_local',
'tramitacao__status']
def __init__(self, *args, **kwargs):
super(RelatorioMateriasTramitacaoilterSet, self).__init__(
*args, **kwargs)
self.filters['tipo'].label = 'Tipo de Matéria'
row1 = to_row([('ano', 12)])
row2 = to_row([('tipo', 12)])
row3 = to_row([('tramitacao__unidade_tramitacao_local', 12)])
row4 = to_row([('tramitacao__status', 12)])
self.form.helper = FormHelper()
self.form.helper.form_method = 'GET'
self.form.helper.layout = Layout(
Fieldset(_('Pesquisa de Matéria em Tramitação'),
row1, row2, row3, row4,
form_actions(save_label='Pesquisar'))
)
class RelatorioMateriasPorAnoAutorTipoFilterSet(django_filters.FilterSet):
ano = django_filters.ChoiceFilter(required=True,
label=u'Ano da Matéria',
choices=RANGE_ANOS)
class Meta:
model = MateriaLegislativa
fields = ['ano']
def __init__(self, *args, **kwargs):
super(RelatorioMateriasPorAnoAutorTipoFilterSet, self).__init__(
*args, **kwargs)
row1 = to_row(
[('ano', 12)])
self.form.helper = FormHelper()
self.form.helper.form_method = 'GET'
self.form.helper.layout = Layout(
Fieldset(_('Pesquisar'),
row1,
form_actions(save_label='Pesquisar'))
)
class RelatorioMateriasPorAutorFilterSet(django_filters.FilterSet):
filter_overrides = {models.DateField: {
'filter_class': django_filters.DateFromToRangeFilter,
'extra': lambda f: {
'label': '%s (%s)' % (f.verbose_name, _('Inicial - Final')),
'widget': RangeWidgetOverride}
}}
autoria__autor = django_filters.CharFilter(widget=forms.HiddenInput())
class Meta:
model = MateriaLegislativa
fields = ['tipo', 'data_apresentacao']
def __init__(self, *args, **kwargs):
super(RelatorioMateriasPorAutorFilterSet, self).__init__(
*args, **kwargs)
self.filters['tipo'].label = 'Tipo de Matéria'
row1 = to_row(
[('tipo', 12)])
row2 = to_row(
[('data_apresentacao', 12)])
row3 = to_row(
[('autoria__autor', 0),
(Button('pesquisar',
'Pesquisar Autor',
css_class='btn btn-primary btn-sm'), 2),
(Button('limpar',
'limpar Autor',
css_class='btn btn-primary btn-sm'), 10)])
self.form.helper = FormHelper()
self.form.helper.form_method = 'GET'
self.form.helper.layout = Layout(
Fieldset(_('Pesquisar'),
row1, row2,
HTML(autor_label),
HTML(autor_modal),
row3,
form_actions(save_label='Pesquisar'))
)
class CasaLegislativaForm(ModelForm): class CasaLegislativaForm(ModelForm):
class Meta: class Meta:

20
sapl/base/urls.py

@ -4,7 +4,11 @@ from django.views.generic.base import TemplateView
from .apps import AppConfig from .apps import AppConfig
from .forms import LoginForm from .forms import LoginForm
from .views import CasaLegislativaCrud, HelpView from .views import (CasaLegislativaCrud, HelpView,
RelatorioHistoricoTramitacaoView,
RelatorioMateriasPorAnoAutorTipoView,
RelatorioMateriasPorAutorView,
RelatorioMateriasTramitacaoView)
app_name = AppConfig.name app_name = AppConfig.name
@ -17,11 +21,23 @@ urlpatterns = [
url(r'^ajuda/(?P<topic>\w+)$', HelpView.as_view(), name='help_topic'), url(r'^ajuda/(?P<topic>\w+)$', HelpView.as_view(), name='help_topic'),
url(r'^ajuda/', TemplateView.as_view(template_name='ajuda/index.html'), url(r'^ajuda/', TemplateView.as_view(template_name='ajuda/index.html'),
name='help_base'), name='help_base'),
url(r'^casa_legislativa/', include(CasaLegislativaCrud.get_urls())), url(r'^casa_legislativa/', include(CasaLegislativaCrud.get_urls())),
url(r'^login/$', views.login, { url(r'^login/$', views.login, {
'template_name': 'base/login.html', 'authentication_form': LoginForm}, 'template_name': 'base/login.html', 'authentication_form': LoginForm},
name='login'), name='login'),
url(r'^logout/$', views.logout, {'next_page': '/login'}, name='logout'), url(r'^logout/$', views.logout, {'next_page': '/login'}, name='logout'),
url(r'^relatorio/materia-por-autor$',
RelatorioMateriasPorAutorView.as_view(), name='materia_por_autor'),
url(r'^relatorio/materia-por-ano-autor-tipo$',
RelatorioMateriasPorAnoAutorTipoView.as_view(),
name='materia_por_ano_autor_tipo'),
url(r'^relatorio/materia-por-tramitacao$',
RelatorioMateriasTramitacaoView.as_view(),
name='materia_por_tramitacao'),
url(r'^relatorio/historico-tramitacoes$',
RelatorioHistoricoTramitacaoView.as_view(),
name='historico_tramitacoes'),
] ]

115
sapl/base/views.py

@ -1,13 +1,19 @@
from django.contrib.auth.mixins import PermissionRequiredMixin from django.contrib.auth.mixins import PermissionRequiredMixin
from django.core.urlresolvers import reverse from django.core.urlresolvers import reverse
from django.http import HttpResponseRedirect from django.http import HttpResponseRedirect
from django.utils.translation import ugettext_lazy as _
from django.views.generic.base import TemplateView from django.views.generic.base import TemplateView
from django_filters.views import FilterView
from sapl.crud.base import (Crud, CrudBaseMixin, CrudCreateView, from sapl.crud.base import (Crud, CrudBaseMixin, CrudCreateView,
CrudDetailView, CrudUpdateView) CrudDetailView, CrudUpdateView)
from sapl.materia.models import MateriaLegislativa, TipoMateriaLegislativa
from sapl.utils import permissao_tb_aux from sapl.utils import permissao_tb_aux
from .forms import CasaLegislativaForm from .forms import (CasaLegislativaForm, RelatorioHistoricoTramitacaoFilterSet,
RelatorioMateriasPorAnoAutorTipoFilterSet,
RelatorioMateriasPorAutorFilterSet,
RelatorioMateriasTramitacaoilterSet)
from .models import CasaLegislativa from .models import CasaLegislativa
@ -15,6 +21,113 @@ def get_casalegislativa():
return CasaLegislativa.objects.first() return CasaLegislativa.objects.first()
class RelatorioHistoricoTramitacaoView(FilterView):
model = MateriaLegislativa
filterset_class = RelatorioHistoricoTramitacaoFilterSet
template_name = 'base/RelatorioHistoricoTramitacao_filter.html'
def get_context_data(self, **kwargs):
context = super(RelatorioHistoricoTramitacaoView,
self).get_context_data(**kwargs)
context['title'] = _('Histórico de Tramitações')
qr = self.request.GET.copy()
context['filter_url'] = ('&' + qr.urlencode()) if len(qr) > 0 else ''
return context
class RelatorioMateriasTramitacaoView(FilterView):
model = MateriaLegislativa
filterset_class = RelatorioMateriasTramitacaoilterSet
template_name = 'base/RelatorioMateriasPorTramitacao_filter.html'
def get_context_data(self, **kwargs):
context = super(RelatorioMateriasTramitacaoView,
self).get_context_data(**kwargs)
context['title'] = _('Matérias por Ano, Autor e Tipo')
qs = context['object_list']
qs = qs.filter(em_tramitacao=True)
context['object_list'] = qs
qtdes = {}
for tipo in TipoMateriaLegislativa.objects.all():
qs = context['object_list']
qtde = len(qs.filter(tipo_id=tipo.id))
if qtde > 0:
qtdes[tipo] = qtde
context['qtdes'] = qtdes
qr = self.request.GET.copy()
context['filter_url'] = ('&' + qr.urlencode()) if len(qr) > 0 else ''
return context
class RelatorioMateriasPorAnoAutorTipoView(FilterView):
model = MateriaLegislativa
filterset_class = RelatorioMateriasPorAnoAutorTipoFilterSet
template_name = 'base/RelatorioMateriasPorAnoAutorTipo_filter.html'
def get_filterset_kwargs(self, filterset_class):
super(RelatorioMateriasPorAnoAutorTipoView,
self).get_filterset_kwargs(filterset_class)
kwargs = {'data': self.request.GET or None}
return kwargs
def get_context_data(self, **kwargs):
context = super(RelatorioMateriasPorAnoAutorTipoView,
self).get_context_data(**kwargs)
context['title'] = _('Matérias por Ano, Autor e Tipo')
qtdes = {}
for tipo in TipoMateriaLegislativa.objects.all():
qs = kwargs['object_list']
qtde = len(qs.filter(tipo_id=tipo.id))
if qtde > 0:
qtdes[tipo] = qtde
context['qtdes'] = qtdes
qr = self.request.GET.copy()
context['filter_url'] = ('&' + qr.urlencode()) if len(qr) > 0 else ''
return context
class RelatorioMateriasPorAutorView(FilterView):
model = MateriaLegislativa
filterset_class = RelatorioMateriasPorAutorFilterSet
template_name = 'base/RelatorioMateriasPorAutor_filter.html'
def get_filterset_kwargs(self, filterset_class):
super(RelatorioMateriasPorAutorView,
self).get_filterset_kwargs(filterset_class)
kwargs = {'data': self.request.GET or None}
return kwargs
def get_context_data(self, **kwargs):
context = super(RelatorioMateriasPorAutorView,
self).get_context_data(**kwargs)
context['title'] = _('Matérias por Autor')
qtdes = {}
for tipo in TipoMateriaLegislativa.objects.all():
qs = kwargs['object_list']
qtde = len(qs.filter(tipo_id=tipo.id))
if qtde > 0:
qtdes[tipo] = qtde
context['qtdes'] = qtdes
qr = self.request.GET.copy()
context['filter_url'] = ('&' + qr.urlencode()) if len(qr) > 0 else ''
return context
class CasaLegislativaCrud(Crud): class CasaLegislativaCrud(Crud):
model = CasaLegislativa model = CasaLegislativa
help_path = '' help_path = ''

5
sapl/materia/views.py

@ -935,11 +935,6 @@ class MateriaLegislativaPesquisaView(FilterView):
context['title'] = _('Pesquisar Matéria Legislativa') context['title'] = _('Pesquisar Matéria Legislativa')
paginator = context['paginator']
page_obj = context['page_obj']
context['page_range'] = make_pagination(
page_obj.number, paginator.num_pages)
self.filterset.form.fields['o'].label = _('Ordenação') self.filterset.form.fields['o'].label = _('Ordenação')
qr = self.request.GET.copy() qr = self.request.GET.copy()

10
sapl/parlamentares/urls.py

@ -5,7 +5,10 @@ from sapl.parlamentares.views import (CargoMesaCrud, ColigacaoCrud,
FiliacaoCrud, LegislaturaCrud, FiliacaoCrud, LegislaturaCrud,
MandatoCrud, MesaDiretoraView, MandatoCrud, MesaDiretoraView,
NivelInstrucaoCrud, ParlamentarCrud, NivelInstrucaoCrud, ParlamentarCrud,
PartidoCrud, SessaoLegislativaCrud, ParticipacaoParlamentarCrud, PartidoCrud,
ProposicaoParlamentarCrud,
RelatoriaParlamentarCrud,
SessaoLegislativaCrud,
TipoAfastamentoCrud, TipoDependenteCrud, TipoAfastamentoCrud, TipoDependenteCrud,
TipoMilitarCrud) TipoMilitarCrud)
@ -16,7 +19,10 @@ app_name = AppConfig.name
urlpatterns = [ urlpatterns = [
url(r'^parlamentar/', include( url(r'^parlamentar/', include(
ParlamentarCrud.get_urls() + DependenteCrud.get_urls() + ParlamentarCrud.get_urls() + DependenteCrud.get_urls() +
FiliacaoCrud.get_urls() + MandatoCrud.get_urls() FiliacaoCrud.get_urls() + MandatoCrud.get_urls() +
ParticipacaoParlamentarCrud.get_urls() +
ProposicaoParlamentarCrud.get_urls() +
RelatoriaParlamentarCrud.get_urls()
)), )),
url(r'^coligacao/', url(r'^coligacao/',
include(ColigacaoCrud.get_urls() + include(ColigacaoCrud.get_urls() +

92
sapl/parlamentares/views.py

@ -2,16 +2,19 @@ from django.contrib import messages
from django.contrib.auth.mixins import PermissionRequiredMixin from django.contrib.auth.mixins import PermissionRequiredMixin
from django.contrib.auth.models import Permission from django.contrib.auth.models import Permission
from django.contrib.contenttypes.models import ContentType from django.contrib.contenttypes.models import ContentType
from django.core.urlresolvers import reverse_lazy from django.core.exceptions import ObjectDoesNotExist
from django.core.urlresolvers import reverse, reverse_lazy
from django.shortcuts import redirect from django.shortcuts import redirect
from django.utils.datastructures import MultiValueDictKeyError from django.utils.datastructures import MultiValueDictKeyError
from django.utils.translation import ugettext_lazy as _ from django.utils.translation import ugettext_lazy as _
from django.views.generic import FormView from django.views.generic import FormView
from sapl.comissoes.models import Participacao
from sapl.crud.base import (Crud, CrudBaseMixin, CrudCreateView, from sapl.crud.base import (Crud, CrudBaseMixin, CrudCreateView,
CrudDeleteView, CrudDetailView, CrudListView, CrudDeleteView, CrudDetailView, CrudListView,
CrudUpdateView) CrudUpdateView)
from sapl.crud.masterdetail import MasterDetailCrud from sapl.crud.masterdetail import MasterDetailCrud
from sapl.materia.models import Proposicao, Relatoria
from sapl.utils import permissao_tb_aux, permissoes_parlamentares from sapl.utils import permissao_tb_aux, permissoes_parlamentares
from .forms import (ComposicaoColigacaoForm, FiliacaoForm, LegislaturaForm, from .forms import (ComposicaoColigacaoForm, FiliacaoForm, LegislaturaForm,
@ -22,6 +25,93 @@ from .models import (CargoMesa, Coligacao, ComposicaoColigacao, ComposicaoMesa,
SituacaoMilitar, TipoAfastamento, TipoDependente) SituacaoMilitar, TipoAfastamento, TipoDependente)
class RelatoriaParlamentarCrud(MasterDetailCrud):
model = Relatoria
parent_field = 'parlamentar'
help_path = ''
class ListView(MasterDetailCrud.ListView):
permission_required = permissoes_parlamentares()
class CreateView(PermissionRequiredMixin, MasterDetailCrud.CreateView):
permission_required = permissoes_parlamentares()
class UpdateView(PermissionRequiredMixin, MasterDetailCrud.UpdateView):
permission_required = permissoes_parlamentares()
class DeleteView(PermissionRequiredMixin, MasterDetailCrud.DeleteView):
permission_required = permissoes_parlamentares()
class ProposicaoParlamentarCrud(MasterDetailCrud):
model = Proposicao
parent_field = 'autor__parlamentar'
help_path = ''
class BaseMixin(CrudBaseMixin):
list_field_names = ['tipo', 'descricao']
class ListView(MasterDetailCrud.ListView):
permission_required = permissoes_parlamentares()
def get_queryset(self):
try:
proposicoes = Proposicao.objects.filter(
autor__parlamentar_id=self.kwargs['pk'],
data_envio__isnull=False)
except ObjectDoesNotExist:
return []
else:
return proposicoes
class CreateView(PermissionRequiredMixin, MasterDetailCrud.CreateView):
permission_required = permissoes_parlamentares()
class UpdateView(PermissionRequiredMixin, MasterDetailCrud.UpdateView):
permission_required = permissoes_parlamentares()
class DeleteView(PermissionRequiredMixin, MasterDetailCrud.DeleteView):
permission_required = permissoes_parlamentares()
class ParticipacaoParlamentarCrud(MasterDetailCrud):
model = Participacao
parent_field = 'parlamentar'
help_path = ''
class ListView(MasterDetailCrud.ListView):
ordering = ('-composicao__periodo')
def get_rows(self, object_list):
comissoes = []
for p in object_list:
if p.cargo.nome != 'Relator':
comissao = [
(p.composicao.comissao.nome, reverse(
'sapl.comissoes:comissao_detail', kwargs={
'pk': p.composicao.comissao.pk})),
(p.cargo.nome, None),
(p.composicao.periodo.data_inicio.strftime(
"%d/%m/%Y") + ' a ' +
p.composicao.periodo.data_fim.strftime("%d/%m/%Y"),
None)
]
comissoes.append(comissao)
return comissoes
def get_headers(self):
return ['Comissão', 'Cargo', 'Período']
class CreateView(PermissionRequiredMixin, MasterDetailCrud.CreateView):
permission_required = permissoes_parlamentares()
class UpdateView(PermissionRequiredMixin, MasterDetailCrud.UpdateView):
permission_required = permissoes_parlamentares()
class DeleteView(PermissionRequiredMixin, MasterDetailCrud.DeleteView):
permission_required = permissoes_parlamentares()
class CargoMesaCrud(Crud): class CargoMesaCrud(Crud):
model = CargoMesa model = CargoMesa
help_path = 'cargo_mesa' help_path = 'cargo_mesa'

16
sapl/sessao/views.py

@ -420,7 +420,7 @@ class SessaoCrud(Crud):
class PresencaMixin: class PresencaMixin:
def get_parlamentares(self): def get_presencas(self):
self.object = self.get_object() self.object = self.get_object()
presencas = SessaoPlenariaPresenca.objects.filter( presencas = SessaoPlenariaPresenca.objects.filter(
@ -434,6 +434,20 @@ class PresencaMixin:
else: else:
yield (parlamentar, False) yield (parlamentar, False)
def get_presencas_ordem(self):
self.object = self.get_object()
presencas = PresencaOrdemDia.objects.filter(
sessao_plenaria_id=self.object.id
)
presentes = [p.parlamentar for p in presencas]
for parlamentar in Parlamentar.objects.filter(ativo=True):
if parlamentar in presentes:
yield (parlamentar, True)
else:
yield (parlamentar, False)
class PresencaView(PermissionRequiredMixin, class PresencaView(PermissionRequiredMixin,
FormMixin, FormMixin,

4
sapl/templates/base.html

@ -79,7 +79,9 @@
<li class="dropdown"> <li class="dropdown">
<a href="#" class="dropdown-toggle" data-toggle="dropdown" role="button" aria-haspopup="true" aria-expanded="false">Atividade Legislativa <span class="caret"></span></a> <a href="#" class="dropdown-toggle" data-toggle="dropdown" role="button" aria-haspopup="true" aria-expanded="false">Atividade Legislativa <span class="caret"></span></a>
<ul class="dropdown-menu"> <ul class="dropdown-menu">
<li class="nav__sub-item"><a class="nav__sub-link" href="{% url 'sapl.materia:proposicao_list' %}">Proposições</a></li> {% if perms.materia.add_proposicao %}
<li class="nav__sub-item"><a class="nav__sub-link" href="{% url 'sapl.materia:proposicao_list' %}">Proposições</a></li>
{% endif %}
<li class="nav__sub-item"><a class="nav__sub-link" href="{% url 'sapl.materia:materialegislativa_list' %}">Matérias Legislativas</a></li> <li class="nav__sub-item"><a class="nav__sub-link" href="{% url 'sapl.materia:materialegislativa_list' %}">Matérias Legislativas</a></li>
<li class="nav__sub-item"><a class="nav__sub-link" href="{% url 'sapl.sessao:sessaoplenaria_list' %}">Sessões Plenárias</a></li> <li class="nav__sub-item"><a class="nav__sub-link" href="{% url 'sapl.sessao:sessaoplenaria_list' %}">Sessões Plenárias</a></li>
<li class="nav__sub-item"><a class="nav__sub-link" href="{% url 'sapl.sessao:list_pauta_sessao' %}">Pautas das Sessões</a></li> <li class="nav__sub-item"><a class="nav__sub-link" href="{% url 'sapl.sessao:list_pauta_sessao' %}">Pautas das Sessões</a></li>

34
sapl/templates/base/RelatorioHistoricoTramitacao_filter.html

@ -0,0 +1,34 @@
{% extends "crud/list.html" %}
{% load i18n %}
{% load crispy_forms_tags %}
{% block base_content %}
{% if not filter_url %}
{% crispy filter.form %}
{% endif %}
{% if filter_url %}
<div class="actions btn-group pull-right" role="group">
<a href="{% url 'sapl.base:historico_tramitacoes' %}" class="btn btn-default">{% trans 'Fazer nova pesquisa' %}</a>
</div>
<br /><br /><br /><br />
<table class="table table-bordered table-hover">
<thead class="thead-default" >
<tr class="active">
<th>Matéria</th>
<th>Ementa</th>
</tr>
</thead>
<tbody>
{% for materia in object_list %}
<tr>
<td><a href="{% url 'sapl.materia:tramitacao_list' materia.pk %}">
{{materia.tipo.descricao}} - {{materia.tipo.sigla}} {{materia.numero}}/{{materia.ano}}
</a></td>
<td>{{materia.ementa}}</td>
</tr>
{% endfor %}
</tbody>
</table>
{% endif %}
{% endblock base_content %}

60
sapl/templates/base/RelatorioMateriasPorAnoAutorTipo_filter.html

@ -0,0 +1,60 @@
{% extends "crud/list.html" %}
{% load i18n %}
{% load crispy_forms_tags %}
{% block base_content %}
{% if not filter_url %}
{% crispy filter.form %}
{% endif %}
{% if filter_url %}
<div class="actions btn-group pull-right" role="group">
<a href="{% url 'sapl.base:materia_por_ano_autor_tipo' %}" class="btn btn-default">{% trans 'Fazer nova pesquisa' %}</a>
</div>
<br /><br /><br /><br />
<table class="table table-bordered table-hover">
<thead class="thead-default" >
<tr class="active"><th colspan="2" class="text-center">QUADRO GERAL</th></tr>
<tr class="active">
<th>Tipo Matéria</th>
<th>Quantidade</th>
</tr>
</thead>
<tbody>
{% for key, value in qtdes.items %}
<tr>
<td>{{key.sigla}} - {{key}}</td>
<td>{{value}}</td>
</tr>
{% endfor %}
</tbody>
</table>
<table class="table table-bordered table-hover">
<thead class="thead-default" >
<tr class="active">
<th>Matéria</th>
<th>Ementa</th>
<th>Autor(es)</th>
</tr>
</thead>
<tbody>
{% for materia in object_list %}
<tr>
<td><a href="{% url 'sapl.materia:materialegislativa_detail' materia.pk %}">
{{materia.tipo.descricao}} - {{materia.tipo.sigla}} {{materia.numero}}/{{materia.ano}}
</a></td>
<td>{{materia.ementa}}</td>
<td>
{% for autor in materia.autoria_set.all %}
{{autor.autor}}<br />
{% endfor %}
</td>
</tr>
{% endfor %}
</tbody>
</table>
{% endif %}
{% endblock base_content %}

60
sapl/templates/base/RelatorioMateriasPorAutor_filter.html

@ -0,0 +1,60 @@
{% extends "crud/list.html" %}
{% load i18n %}
{% load crispy_forms_tags %}
{% block base_content %}
{% if not filter_url %}
{% crispy filter.form %}
{% endif %}
{% if filter_url %}
<div class="actions btn-group pull-right" role="group">
<a href="{% url 'sapl.base:materia_por_autor' %}" class="btn btn-default">{% trans 'Fazer nova pesquisa' %}</a>
</div>
<br /><br /><br /><br />
<table class="table table-bordered table-hover">
<thead class="thead-default" >
<tr class="active"><th colspan="2" class="text-center">QUADRO GERAL</th></tr>
<tr class="active">
<th>Tipo Matéria</th>
<th>Quantidade</th>
</tr>
</thead>
<tbody>
{% for key, value in qtdes.items %}
<tr>
<td>{{key.sigla}} - {{key}}</td>
<td>{{value}}</td>
</tr>
{% endfor %}
</tbody>
</table>
<table class="table table-bordered table-hover">
<thead class="thead-default" >
<tr class="active">
<th>Matéria</th>
<th>Ementa</th>
<th>Autor(es)</th>
</tr>
</thead>
<tbody>
{% for materia in object_list %}
<tr>
<td><a href="{% url 'sapl.materia:materialegislativa_detail' materia.pk %}">
{{materia.tipo.sigla}} {{materia.numero}}/{{materia.ano}}
</a></td>
<td>{{materia.ementa}}</td>
<td>
{% for autor in materia.autoria_set.all %}
{{autor.autor}}<br />
{% endfor %}
</td>
</tr>
{% endfor %}
</tbody>
</table>
{% endif %}
{% endblock base_content %}

56
sapl/templates/base/RelatorioMateriasPorTramitacao_filter.html

@ -0,0 +1,56 @@
{% extends "crud/list.html" %}
{% load i18n %}
{% load crispy_forms_tags %}
{% block base_content %}
{% if not filter_url %}
{% crispy filter.form %}
{% endif %}
{% if filter_url %}
<div class="actions btn-group pull-right" role="group">
<a href="{% url 'sapl.base:materia_por_tramitacao' %}" class="btn btn-default">{% trans 'Fazer nova pesquisa' %}</a>
</div>
<br /><br /><br /><br />
<table class="table table-bordered table-hover">
<thead class="thead-default" >
<tr class="active"><th colspan="2" class="text-center">QUADRO GERAL</th></tr>
<tr class="active">
<th>Tipo Matéria</th>
<th>Quantidade</th>
</tr>
</thead>
<tbody>
{% for key, value in qtdes.items %}
<tr>
<td>{{key.sigla}} - {{key}}</td>
<td>{{value}}</td>
</tr>
{% endfor %}
</tbody>
</table>
<table class="table table-bordered table-hover">
<thead class="thead-default" >
<tr class="active">
<th>Matéria</th>
<th>Local Atual</th>
<th>Status</th>
</tr>
</thead>
<tbody>
{% for materia in object_list %}
<tr>
<td><a href="{% url 'sapl.materia:materialegislativa_detail' materia.pk %}">
{{materia.tipo.descricao}} {{materia.numero}}/{{materia.ano}}
</a></td>
<td>{{materia.tramitacao_set.last.unidade_tramitacao_local}}</td>
<td>{{materia.tramitacao_set.last.status}}</td>
</tr>
{% endfor %}
</tbody>
</table>
{% endif %}
{% endblock base_content %}

18
sapl/templates/base/relatorios_list.html

@ -13,16 +13,16 @@
</thead> </thead>
<tbody> <tbody>
<tr> <tr>
<td><a href="">Matérias em tramitação</a></td> <td><a href="{% url 'sapl.base:materia_por_tramitacao' %}">Matérias em tramitação</a></td>
<td>Matérias Legislativas por Ano, Tipo, Local atual e Status da Tramitação informados.</td> <td> Matérias Legislativas por Ano, Tipo, Local atual e Status da Tramitação informados. </td>
</tr> </tr>
<tr> <tr>
<td><a href="">Proposituras por Tipo, Autor e Ano</a></td> <td><a href="{% url 'sapl.base:materia_por_autor' %}">Matérias por Autor</a></td>
<td>Número de matérias legislativas, agrupadas por Tipo e Autor e Ano selecionado.</td> <td> Listagem e totalização de matérias por autor, com filtros para tipo e período. </td>
</tr> </tr>
<tr> <tr>
<td><a href="">Proposituras por Autor</a></td> <td><a href="{% url 'sapl.base:materia_por_ano_autor_tipo' %}">Matérias por Ano, Autor e Tipo</a></td>
<td>Resumo de Proposituras de um determinado ano, agrupadas por Autor.</td> <td> Totalização anual de matérias agrupadas por autor e tipo. </td>
</tr> </tr>
<tr> <tr>
<td><a href="">Presença nas sessões</a></td> <td><a href="">Presença nas sessões</a></td>
@ -30,11 +30,11 @@
</tr> </tr>
<tr> <tr>
<td><a href="">Atas</a></td> <td><a href="">Atas</a></td>
<td>Matérias Legislativas por Ano, Tipo, Local atual e Status da Tramitação informados.</td> <td> Atas de Sessão Plenária. </td>
</tr> </tr>
<tr> <tr>
<td><a href="">Histórico de tramitações</a></td> <td><a href="{% url 'sapl.base:historico_tramitacoes' %}">Histórico de tramitações</a></td>
<td>Histórico de tramitações por período e local informados.</td> <td> Histórico de tramitações por período e local informados. </td>
</tr> </tr>
</tbody> </tbody>
</table> </table>

6
sapl/templates/parlamentares/subnav.yaml

@ -7,3 +7,9 @@
url: filiacao_list url: filiacao_list
- title: {% trans 'Dependentes' %} - title: {% trans 'Dependentes' %}
url: dependente_list url: dependente_list
- title: {% trans 'Comissões' %}
url: participacao_list
- title: {% trans 'Proposições' %}
url: proposicao_list
- title: {% trans 'Relatorias' %}
url: relatoria_list

2
sapl/templates/sessao/presenca.html

@ -14,7 +14,7 @@
<div class="col-md-12"><input type="checkbox" onClick="checkAll(this)" /> Marcar/Desmarcar Todos</div> <div class="col-md-12"><input type="checkbox" onClick="checkAll(this)" /> Marcar/Desmarcar Todos</div>
</div> </div>
{% for parlamentar, check in view.get_parlamentares %} {% for parlamentar, check in view.get_presencas %}
<div class="row"> <div class="row">
<div class="col-md-6"><input type="checkbox" name="presenca" value="{{ parlamentar.id }}" {% if check %} checked {% endif %}/></div> <div class="col-md-6"><input type="checkbox" name="presenca" value="{{ parlamentar.id }}" {% if check %} checked {% endif %}/></div>
<div class="col-md-6"><label for="parlamentar">{{ parlamentar }}</label></div> <div class="col-md-6"><label for="parlamentar">{{ parlamentar }}</label></div>

2
sapl/templates/sessao/presenca_ordemdia.html

@ -14,7 +14,7 @@
<div class="col-md-12"><input type="checkbox" onClick="checkAll(this)" /> Marcar/Desmarcar Todos</div> <div class="col-md-12"><input type="checkbox" onClick="checkAll(this)" /> Marcar/Desmarcar Todos</div>
</div> </div>
{% for parlamentar, check in view.get_parlamentares %} {% for parlamentar, check in view.get_presencas_ordem %}
<div class="row"> <div class="row">
<div class="col-md-6"><input type="checkbox" name="presenca" value="{{ parlamentar.id }}" {% if check %} checked {% endif %}/></div> <div class="col-md-6"><input type="checkbox" name="presenca" value="{{ parlamentar.id }}" {% if check %} checked {% endif %}/></div>
<div class="col-md-6"><label for="parlamentar">{{ parlamentar }}</label></div> <div class="col-md-6"><label for="parlamentar">{{ parlamentar }}</label></div>

106
sapl/utils.py

@ -222,98 +222,58 @@ def intervalos_tem_intersecao(a_inicio, a_fim, b_inicio, b_fim):
return maior_inicio <= menor_fim return maior_inicio <= menor_fim
def permissoes_materia(): def permissoes(nome_grupo, app_label):
lista_permissoes = [] lista_permissoes = []
try: try:
perms_materia = Permission.objects.filter( perms = list(Permission.objects.filter(
group__name='Operador de Matéria') group__name=nome_grupo))
for p in perms_materia: for p in perms:
lista_permissoes.append('materia.' + p.codename) lista_permissoes.append('%s.%s' % (app_label, p.codename))
except: except:
pass pass
return set(lista_permissoes) return set(lista_permissoes)
def permissoes_comissoes(): def permissoes_materia():
lista_permissoes = [] return permissoes('Operador de Matéria', 'materia')
try:
cts = ContentType.objects.filter(app_label='comissoes')
perms_comissoes = list(Permission.objects.filter(content_type__in=cts))
for p in perms_comissoes:
lista_permissoes.append('comissoes.' + p.codename)
except:
pass
return set(lista_permissoes)
def permissoes_norma(): def permissoes_comissoes():
lista_permissoes = [] return permissoes('Operador de Comissões', 'comissoes')
try:
cts = ContentType.objects.filter(app_label='norma')
perms_norma = list(Permission.objects.filter(content_type__in=cts))
for p in perms_norma:
lista_permissoes.append('norma.' + p.codename)
except:
pass
return set(lista_permissoes)
def permissoes_parlamentares(): def permissoes_norma():
lista_permissoes = [] return permissoes('Operador de Norma Jurídica', 'norma')
try:
cts = ContentType.objects.filter(app_label='parlamentares')
perms_parlamentares = list(Permission.objects.filter(
content_type__in=cts))
for p in perms_parlamentares:
lista_permissoes.append('parlamentares.' + p.codename)
except:
pass
return set(lista_permissoes)
def permissoes_protocoloadm(): def permissoes_protocoloadm():
lista_permissoes = [] return permissoes('Operador de Protocolo Administrativo', 'protocoloadm')
try:
perms_protocolo = Permission.objects.filter(
group__name='Operador de Protocolo Administrativo')
for p in perms_protocolo:
lista_permissoes.append('protocoloadm.' + p.codename)
except:
pass
return set(lista_permissoes)
def permissoes_adm(): def permissoes_adm():
lista_permissoes = [] return permissoes('Operador Administrativo', 'protocoloadm')
try:
perms_adm = Permission.objects.filter(
group__name='Operador Administrativo')
for p in perms_adm:
lista_permissoes.append('protocoloadm.' + p.codename)
except:
pass
return set(lista_permissoes)
def permissoes_sessao(): def permissoes_sessao():
lista_permissoes = [] return permissoes('Operador de Sessão Plenária', 'sessao')
try:
perms_sessao = list(Permission.objects.filter(
group__name='Operador de Sessão Plenária'))
for p in perms_sessao:
lista_permissoes.append('sessao.' + p.codename)
except:
pass
return set(lista_permissoes)
def permissoes_painel(): def permissoes_painel():
return permissoes('Operador de Painel Eletrônico', 'sessao')
def permissoes_autor():
return permissoes('Autor', 'materia')
def permissoes_parlamentares():
lista_permissoes = [] lista_permissoes = []
try: try:
perms_painel = list(Permission.objects.filter( cts = ContentType.objects.filter(app_label='parlamentares')
group__name='Operador de Painel Eletrônico')) perms_parlamentares = list(Permission.objects.filter(
for p in perms_painel: content_type__in=cts))
lista_permissoes.append('painel.' + p.codename) for p in perms_parlamentares:
lista_permissoes.append('parlamentares.' + p.codename)
except: except:
pass pass
return set(lista_permissoes) return set(lista_permissoes)
@ -327,18 +287,6 @@ def permissao_tb_aux(self):
return False return False
def permissoes_autor():
lista_permissoes = []
try:
perms_autor = list(Permission.objects.filter(
group__name='Autor'))
for p in perms_autor:
lista_permissoes.append('materia.' + p.codename)
except:
pass
return set(lista_permissoes)
def gerar_hash_arquivo(arquivo, pk, block_size=2**20): def gerar_hash_arquivo(arquivo, pk, block_size=2**20):
md5 = hashlib.md5() md5 = hashlib.md5()
arq = open(arquivo, 'rb') arq = open(arquivo, 'rb')

Loading…
Cancel
Save