Browse Source

Implementa view e form para pesquisa de presença em sessão

pull/568/head
Eduardo Edson Batista Cordeiro Alves 8 years ago
parent
commit
4fbe0a95df
  1. 30
      sapl/base/forms.py
  2. 6
      sapl/base/urls.py
  3. 18
      sapl/base/views.py
  4. 40
      sapl/templates/base/RelatorioPresencaSessao_filter.html
  5. 2
      sapl/templates/base/relatorios_list.html

30
sapl/base/forms.py

@ -10,6 +10,7 @@ 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.sessao.models import SessaoPlenaria
from sapl.settings import MAX_IMAGE_UPLOAD_SIZE
from sapl.utils import (RANGE_ANOS, ImageThumbnailFileInput, autor_label,
autor_modal)
@ -37,6 +38,35 @@ class RangeWidgetOverride(forms.MultiWidget):
return ''.join(rendered_widgets)
class RelatorioPresencaSessaoFilterSet(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 = SessaoPlenaria
fields = ['data_inicio']
def __init__(self, *args, **kwargs):
super(RelatorioPresencaSessaoFilterSet, self).__init__(
*args, **kwargs)
self.filters['data_inicio'].label = 'Período'
row1 = to_row([('data_inicio', 12)])
self.form.helper = FormHelper()
self.form.helper.form_method = 'GET'
self.form.helper.layout = Layout(
Fieldset(_('Presença dos parlamentares nas sessões plenárias'),
row1, form_actions(save_label='Pesquisar'))
)
class RelatorioHistoricoTramitacaoFilterSet(django_filters.FilterSet):
filter_overrides = {models.DateField: {

6
sapl/base/urls.py

@ -8,7 +8,8 @@ from .views import (CasaLegislativaCrud, HelpView,
RelatorioHistoricoTramitacaoView,
RelatorioMateriasPorAnoAutorTipoView,
RelatorioMateriasPorAutorView,
RelatorioMateriasTramitacaoView)
RelatorioMateriasTramitacaoView,
RelatorioPresencaSessaoView)
app_name = AppConfig.name
@ -39,5 +40,8 @@ urlpatterns = [
url(r'^relatorio/historico-tramitacoes$',
RelatorioHistoricoTramitacaoView.as_view(),
name='historico_tramitacoes'),
url(r'^relatorio/presenca$',
RelatorioPresencaSessaoView.as_view(),
name='presenca_sessao'),
]

18
sapl/base/views.py

@ -9,11 +9,13 @@ from sapl.crud.base import (Crud, CrudBaseMixin, CrudCreateView,
CrudDetailView, CrudUpdateView)
from sapl.materia.models import MateriaLegislativa, TipoMateriaLegislativa
from sapl.utils import permissao_tb_aux
from sapl.sessao.models import SessaoPlenaria
from .forms import (CasaLegislativaForm, RelatorioHistoricoTramitacaoFilterSet,
RelatorioMateriasPorAnoAutorTipoFilterSet,
RelatorioMateriasPorAutorFilterSet,
RelatorioMateriasTramitacaoilterSet)
RelatorioMateriasTramitacaoilterSet,
RelatorioPresencaSessaoFilterSet)
from .models import CasaLegislativa
@ -21,6 +23,20 @@ def get_casalegislativa():
return CasaLegislativa.objects.first()
class RelatorioPresencaSessaoView(FilterView):
model = SessaoPlenaria
filterset_class = RelatorioPresencaSessaoFilterSet
template_name = 'base/RelatorioPresencaSessao_filter.html'
def get_context_data(self, **kwargs):
context = super(RelatorioPresencaSessaoView,
self).get_context_data(**kwargs)
context['title'] = _('Presença dos parlamentares nas sessões')
qr = self.request.GET.copy()
context['filter_url'] = ('&' + qr.urlencode()) if len(qr) > 0 else ''
return context
class RelatorioHistoricoTramitacaoView(FilterView):
model = MateriaLegislativa
filterset_class = RelatorioHistoricoTramitacaoFilterSet

40
sapl/templates/base/RelatorioPresencaSessao_filter.html

@ -0,0 +1,40 @@
{% 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:presenca_sessao' %}" 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" align="center">
<tr class="active">
<th rowspan="2" align="left">Nome Parlamentar / Partido</th>
<th colspan="2" align="center">Sessão</th>
<th colspan="2" align="center">Ordem do Dia</th>
</tr>
<tr class="active">
<th align="center">(Qtd)</th>
<th align="center">( % )</th>
<th align="center">(Qtd)</th>
<th align="center">( % )</th>
</tr>
</thead>
<tbody>
<tr>
<td align="left">Nome Teste / Partido Teste</td>
<td align="center">15</td>
<td align="center">11%</td>
<td align="center">1</td>
<td align="center">16%</td>
</tr>
</tbody>
</table>
{% endif %}
{% endblock base_content %}

2
sapl/templates/base/relatorios_list.html

@ -25,7 +25,7 @@
<td> Totalização anual de matérias agrupadas por autor e tipo. </td>
</tr>
<tr>
<td><a href="">Presença nas sessões</a></td>
<td><a href="{% url 'sapl.base:presenca_sessao' %}">Presença nas sessões</a></td>
<td>Presença dos parlamentares nas sessões plenárias.</td>
</tr>
<tr>

Loading…
Cancel
Save