Browse Source

Adiciona pesquisa de sessões com ata por data

pull/569/head
Eduardo Edson Batista Cordeiro Alves 8 years ago
parent
commit
e6e1214c88
  1. 30
      sapl/base/forms.py
  2. 5
      sapl/base/urls.py
  3. 23
      sapl/base/views.py
  4. 38
      sapl/templates/base/RelatorioAtas_filter.html
  5. 2
      sapl/templates/base/relatorios_list.html
  6. 6
      sapl/templates/sessao/pauta_sessao_list.html

30
sapl/base/forms.py

@ -38,6 +38,36 @@ class RangeWidgetOverride(forms.MultiWidget):
return ''.join(rendered_widgets)
class RelatorioAtasFilterSet(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(RelatorioAtasFilterSet, self).__init__(
*args, **kwargs)
self.filters['data_inicio'].label = 'Período (Inicial - Final)'
self.form.fields['data_inicio'].required = True
row1 = to_row([('data_inicio', 12)])
self.form.helper = FormHelper()
self.form.helper.form_method = 'GET'
self.form.helper.layout = Layout(
Fieldset(_('Atas das Sessões Plenárias'),
row1, form_actions(save_label='Pesquisar'))
)
class RelatorioPresencaSessaoFilterSet(django_filters.FilterSet):
filter_overrides = {models.DateField: {

5
sapl/base/urls.py

@ -4,7 +4,7 @@ from django.views.generic.base import TemplateView
from .apps import AppConfig
from .forms import LoginForm
from .views import (CasaLegislativaCrud, HelpView,
from .views import (CasaLegislativaCrud, HelpView, RelatorioAtasView,
RelatorioHistoricoTramitacaoView,
RelatorioMateriasPorAnoAutorTipoView,
RelatorioMateriasPorAutorView,
@ -43,5 +43,8 @@ urlpatterns = [
url(r'^relatorio/presenca$',
RelatorioPresencaSessaoView.as_view(),
name='presenca_sessao'),
url(r'^relatorio/atas$',
RelatorioAtasView.as_view(),
name='atas'),
]

23
sapl/base/views.py

@ -16,7 +16,8 @@ from sapl.sessao.models import (OrdemDia, PresencaOrdemDia, SessaoPlenaria,
SessaoPlenariaPresenca)
from sapl.utils import permissao_tb_aux
from .forms import (CasaLegislativaForm, RelatorioHistoricoTramitacaoFilterSet,
from .forms import (CasaLegislativaForm, RelatorioAtasFilterSet,
RelatorioHistoricoTramitacaoFilterSet,
RelatorioMateriasPorAnoAutorTipoFilterSet,
RelatorioMateriasPorAutorFilterSet,
RelatorioMateriasTramitacaoilterSet,
@ -28,6 +29,26 @@ def get_casalegislativa():
return CasaLegislativa.objects.first()
class RelatorioAtasView(FilterView):
model = SessaoPlenaria
filterset_class = RelatorioAtasFilterSet
template_name = 'base/RelatorioAtas_filter.html'
def get_context_data(self, **kwargs):
context = super(RelatorioAtasView,
self).get_context_data(**kwargs)
context['title'] = _('Atas das Sessões Plenárias')
# Verifica se os campos foram preenchidos
if not self.filterset.form.is_valid():
return context
context['object_list'] = context['object_list'].exclude(upload_ata='')
qr = self.request.GET.copy()
context['filter_url'] = ('&' + qr.urlencode()) if len(qr) > 0 else ''
return context
class RelatorioPresencaSessaoView(FilterView):
model = SessaoPlenaria
filterset_class = RelatorioPresencaSessaoFilterSet

38
sapl/templates/base/RelatorioAtas_filter.html

@ -0,0 +1,38 @@
{% extends "crud/list.html" %}
{% load i18n %}
{% load crispy_forms_tags staticfiles %}
{% 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:atas' %}" class="btn btn-default">{% trans 'Fazer nova pesquisa' %}</a>
</div>
<br /><br /><br />
{% if object_list|length > 0 %}
<table class="table table-striped table-hover">
<thead>
<tr>
<th>Sessão</th>
<th>Ata</th>
</tr>
</thead>
<tbody>
{% for sessao in object_list %}
<tr>
<td>{{sessao}}</td>
<td><a href="{{ sessao.upload_ata.url }}">
<img src="{% static 'img/file.png' %}">
</a></td>
</tr>
{% endfor %}
</tbody>
</table>
{% else %}
<font size="5"><p align="center">Nenhum sessão com ata foi encontrada!</p></font>
{% endif %}
{% endif %}
{% endblock base_content %}

2
sapl/templates/base/relatorios_list.html

@ -29,7 +29,7 @@
<td>Presença dos parlamentares nas sessões plenárias.</td>
</tr>
<tr>
<td><a href="">Atas</a></td>
<td><a href="{% url 'sapl.base:atas' %}">Atas</a></td>
<td> Atas de Sessão Plenária. </td>
</tr>
<tr>

6
sapl/templates/sessao/pauta_sessao_list.html

@ -9,7 +9,6 @@
<table class="table table-striped table-hover">
<thead>
<tr>
<th>Data</th>
<th>Sessão</th>
<th>PDF</th>
</tr>
@ -17,9 +16,6 @@
<tbody>
{% for sessao in page_obj %}
<tr>
<td><a href="{% url 'sapl.sessao:pauta_sessao_detail' sessao.id %}">
{{sessao.data_inicio}} - {{sessao.hora_inicio}}
</a></td>
<td>{{sessao}}</td>
<td><a href="{% url 'sapl.relatorios:relatorio_sessao_plenaria' sessao.id %}">
<img src="{% static 'img/file.png' %}">
@ -29,6 +25,4 @@
</tbody>
</table>
{% endif %}
{% include "paginacao.html" %}
{% endblock %}

Loading…
Cancel
Save