Browse Source

Fix #1474 bug iframe telas pesquisa (#1478)

* Fix #1474

* Conserta PEP8

* Melhoria no código
pull/1483/head
Eduardo Calil 7 years ago
committed by Edward
parent
commit
7455602740
  1. 18
      sapl/base/views.py
  2. 1
      sapl/materia/tests/test_materia.py
  3. 4
      sapl/materia/tests/test_materia_form.py
  4. 4
      sapl/materia/urls.py
  5. 19
      sapl/materia/views.py
  6. 3
      sapl/norma/views.py
  7. 5
      sapl/parlamentares/views.py
  8. 8
      sapl/protocoloadm/views.py
  9. 5
      sapl/sessao/urls.py
  10. 5
      sapl/sessao/views.py
  11. 4
      sapl/templates/base/RelatorioHistoricoTramitacao_filter.html
  12. 4
      sapl/templates/base/RelatorioMateriasPorAnoAutorTipo_filter.html
  13. 4
      sapl/templates/base/RelatorioMateriasPorAutor_filter.html
  14. 4
      sapl/templates/base/RelatorioPresencaSessao_filter.html
  15. 4
      sapl/templates/materia/em_lote/acessorio.html
  16. 4
      sapl/templates/materia/em_lote/tramitacao.html
  17. 6
      sapl/templates/materia/materialegislativa_filter.html
  18. 6
      sapl/templates/norma/normajuridica_filter.html
  19. 6
      sapl/templates/protocoloadm/documentoadministrativo_filter.html
  20. 8
      sapl/templates/protocoloadm/protocolo_filter.html
  21. 2
      sapl/templates/sessao/sessaoplenaria_filter.html
  22. 9
      sapl/utils.py

18
sapl/base/views.py

@ -23,7 +23,8 @@ from sapl.materia.models import (Autoria, MateriaLegislativa,
TipoMateriaLegislativa)
from sapl.sessao.models import (PresencaOrdemDia, SessaoPlenaria,
SessaoPlenariaPresenca)
from sapl.utils import parlamentares_ativos, sapl_logger
from sapl.utils import (parlamentares_ativos, sapl_logger,\
show_results_filter_set)
from .forms import (CasaLegislativaForm, ConfiguracoesAppForm,
RelatorioAtasFilterSet,
@ -202,6 +203,9 @@ class RelatorioAtasView(FilterView):
context['object_list'] = context['object_list'].exclude(upload_ata='')
qr = self.request.GET.copy()
context['filter_url'] = ('&' + qr.urlencode()) if len(qr) > 0 else ''
context['show_results'] = show_results_filter_set(qr)
return context
@ -294,6 +298,9 @@ class RelatorioPresencaSessaoView(FilterView):
# =====================================================================
qr = self.request.GET.copy()
context['filter_url'] = ('&' + qr.urlencode()) if len(qr) > 0 else ''
context['show_results'] = show_results_filter_set(qr)
return context
@ -308,6 +315,9 @@ class RelatorioHistoricoTramitacaoView(FilterView):
context['title'] = _('Histórico de Tramitações')
qr = self.request.GET.copy()
context['filter_url'] = ('&' + qr.urlencode()) if len(qr) > 0 else ''
context['show_results'] = show_results_filter_set(qr)
return context
@ -337,6 +347,8 @@ class RelatorioMateriasTramitacaoView(FilterView):
qr = self.request.GET.copy()
context['filter_url'] = ('&' + qr.urlencode()) if len(qr) > 0 else ''
context['show_results'] = show_results_filter_set(qr)
return context
@ -409,6 +421,8 @@ class RelatorioMateriasPorAnoAutorTipoView(FilterView):
qr = self.request.GET.copy()
context['filter_url'] = ('&' + qr.urlencode()) if len(qr) > 0 else ''
context['show_results'] = show_results_filter_set(qr)
if 'ano' in self.request.GET and self.request.GET['ano']:
ano = int(self.request.GET['ano'])
context['relatorio'] = self.get_materias_autor_ano(ano)
@ -447,6 +461,8 @@ class RelatorioMateriasPorAutorView(FilterView):
qr = self.request.GET.copy()
context['filter_url'] = ('&' + qr.urlencode()) if len(qr) > 0 else ''
context['show_results'] = show_results_filter_set(qr)
return context

1
sapl/materia/tests/test_materia.py

@ -17,6 +17,7 @@ from sapl.norma.models import (LegislacaoCitada, NormaJuridica,
TipoNormaJuridica)
from sapl.utils import models_with_gr_for_model
@pytest.mark.django_db(transaction=False)
def make_unidade_tramitacao(descricao):
# Cria uma comissão para ser a unidade de tramitação

4
sapl/materia/tests/test_materia_form.py

@ -3,7 +3,8 @@ from django.utils.translation import ugettext as _
from model_mommy import mommy
from sapl.materia import forms
from sapl.materia.models import (MateriaLegislativa, TipoMateriaLegislativa)
from sapl.materia.models import MateriaLegislativa, TipoMateriaLegislativa
@pytest.mark.django_db(transaction=False)
def test_valida_campos_obrigatorios_ficha_pesquisa_form():
@ -19,6 +20,7 @@ def test_valida_campos_obrigatorios_ficha_pesquisa_form():
assert len(errors) == 3
@pytest.mark.django_db(transaction=False)
def test_ficha_pesquisa_form_datas_invalidas():
tipo = mommy.make(TipoMateriaLegislativa)

4
sapl/materia/urls.py

@ -8,8 +8,8 @@ from sapl.materia.views import (AcompanhamentoConfirmarView,
CriarProtocoloMateriaView, DespachoInicialCrud,
DocumentoAcessorioCrud,
DocumentoAcessorioEmLoteView,
ImpressosView, EtiquetaPesquisaView,
FichaPesquisaView, FichaSelecionaView,
EtiquetaPesquisaView, FichaPesquisaView,
FichaSelecionaView, ImpressosView,
LegislacaoCitadaCrud, MateriaAssuntoCrud,
MateriaLegislativaCrud,
MateriaLegislativaPesquisaView, MateriaTaView,

19
sapl/materia/views.py

@ -14,7 +14,7 @@ from django.core.urlresolvers import reverse
from django.http import HttpResponse, JsonResponse
from django.http.response import Http404, HttpResponseRedirect
from django.shortcuts import get_object_or_404, redirect
from django.template import loader, RequestContext
from django.template import RequestContext, loader
from django.utils import formats
from django.utils.translation import ugettext_lazy as _
from django.views.generic import CreateView, ListView, TemplateView, UpdateView
@ -42,7 +42,7 @@ from sapl.norma.models import LegislacaoCitada
from sapl.protocoloadm.models import Protocolo
from sapl.utils import (TURNO_TRAMITACAO_CHOICES, YES_NO_CHOICES, autor_label,
autor_modal, gerar_hash_arquivo, get_base_url,
montar_row_autor)
montar_row_autor, show_results_filter_set)
from .email_utils import do_envia_email_confirmacao
from .forms import (AcessorioEmLoteFilterSet, AcompanhamentoMateriaForm,
@ -138,6 +138,9 @@ class AdicionarVariasAutorias(PermissionRequiredForAppCrudMixin, FilterView):
context['title'] = _('Pesquisar Autores')
qr = self.request.GET.copy()
context['filter_url'] = ('&' + qr.urlencode()) if len(qr) > 0 else ''
context['show_results'] = show_results_filter_set(qr)
context['pk_materia'] = self.kwargs['pk']
return context
@ -1509,6 +1512,8 @@ class MateriaLegislativaPesquisaView(FilterView):
context['filter_url'] = ('&' + qr.urlencode()) if len(qr) > 0 else ''
context['show_results'] = show_results_filter_set(qr)
return context
@ -1610,6 +1615,9 @@ class DocumentoAcessorioEmLoteView(PermissionRequiredMixin, FilterView):
context['object_list'] = context['object_list'].order_by(
'ano', 'numero')
context['filter_url'] = ('&' + qr.urlencode()) if len(qr) > 0 else ''
context['show_results'] = show_results_filter_set(qr)
return context
def post(self, request, *args, **kwargs):
@ -1677,6 +1685,9 @@ class PrimeiraTramitacaoEmLoteView(PermissionRequiredMixin, FilterView):
'ano', 'numero')
context['filter_url'] = ('&' + qr.urlencode()) if len(qr) > 0 else ''
context['show_results'] = show_results_filter_set(qr)
return context
def post(self, request, *args, **kwargs):
@ -1819,6 +1830,7 @@ class FichaPesquisaView(PermissionRequiredMixin, FormView):
return HttpResponseRedirect(url)
class FichaSelecionaView(PermissionRequiredMixin, FormView):
form_class = FichaSelecionaForm
template_name = 'materia/impressos/ficha_seleciona.html'
@ -1846,7 +1858,8 @@ class FichaSelecionaView(PermissionRequiredMixin, FormView):
context['quantidade'] = len(materia_list)
materia_list = materia_list[:20]
context['form'].fields['materia'].choices = [(m.id, str(m)) for m in materia_list]
context['form'].fields['materia'].choices = [
(m.id, str(m)) for m in materia_list]
if context['quantidade'] > 20:
messages.info(self.request, _('Sua pesquisa retornou mais do que '

3
sapl/norma/views.py

@ -11,6 +11,7 @@ from sapl.base.models import AppConfig
from sapl.compilacao.views import IntegracaoTaView
from sapl.crud.base import (RP_DETAIL, RP_LIST, Crud, CrudAux,
MasterDetailCrud, make_pagination)
from sapl.utils import show_results_filter_set
from .forms import NormaFilterSet, NormaJuridicaForm, NormaRelacionadaForm
from .models import (AssuntoNorma, NormaJuridica, NormaRelacionada,
@ -81,6 +82,8 @@ class NormaPesquisaView(FilterView):
context['filter_url'] = ('&' + qr.urlencode()) if len(qr) > 0 else ''
context['show_results'] = show_results_filter_set(qr)
return context

5
sapl/parlamentares/views.py

@ -25,9 +25,8 @@ from sapl.materia.models import Autoria, Proposicao, Relatoria
from sapl.parlamentares.apps import AppConfig
from sapl.utils import parlamentares_ativos
from .forms import (FiliacaoForm, LegislaturaForm,
MandatoForm, ParlamentarCreateForm, ParlamentarForm,
VotanteForm)
from .forms import (FiliacaoForm, LegislaturaForm, MandatoForm,
ParlamentarCreateForm, ParlamentarForm, VotanteForm)
from .models import (CargoMesa, Coligacao, ComposicaoColigacao, ComposicaoMesa,
Dependente, Filiacao, Frente, Legislatura, Mandato,
NivelInstrucao, Parlamentar, Partido, SessaoLegislativa,

8
sapl/protocoloadm/views.py

@ -21,7 +21,7 @@ from sapl.crud.base import Crud, CrudAux, MasterDetailCrud, make_pagination
from sapl.materia.models import MateriaLegislativa, TipoMateriaLegislativa
from sapl.parlamentares.models import Legislatura, Parlamentar
from sapl.protocoloadm.models import Protocolo
from sapl.utils import create_barcode, get_client_ip
from sapl.utils import create_barcode, get_client_ip, show_results_filter_set
from .forms import (AnularProcoloAdmForm, DocumentoAcessorioAdministrativoForm,
DocumentoAdministrativoFilterSet,
@ -212,6 +212,9 @@ class ProtocoloPesquisaView(PermissionRequiredMixin, FilterView):
numero_res=len(self.object_list)
)
context['show_results'] = show_results_filter_set(
self.request.GET.copy())
return self.render_to_response(context)
@ -564,6 +567,9 @@ class PesquisarDocumentoAdministrativoView(DocumentoAdministrativoMixin,
numero_res=len(self.object_list)
)
context['show_results'] = show_results_filter_set(
self.request.GET.copy())
return self.render_to_response(context)

5
sapl/sessao/urls.py

@ -19,9 +19,8 @@ from sapl.sessao.views import (AdicionarVariasMateriasExpediente,
VotacaoNominalExpedienteDetailView,
VotacaoNominalExpedienteEditView,
VotacaoNominalExpedienteView,
VotacaoNominalView, VotacaoView,
abrir_votacao, atualizar_mesa,
insere_parlamentar_composicao,
VotacaoNominalView, VotacaoView, abrir_votacao,
atualizar_mesa, insere_parlamentar_composicao,
mudar_ordem_materia_sessao, recuperar_materia,
recuperar_numero_sessao,
remove_parlamentar_composicao,

5
sapl/sessao/views.py

@ -34,6 +34,7 @@ from sapl.parlamentares.models import (Filiacao, Legislatura, Mandato,
Parlamentar, SessaoLegislativa)
from sapl.sessao.apps import AppConfig
from sapl.sessao.forms import ExpedienteMateriaForm, OrdemDiaForm
from sapl.utils import show_results_filter_set
from .forms import (AdicionarVariasMateriasFilterSet, ExpedienteForm,
ListMateriaForm, MesaForm, OradorExpedienteForm,
@ -117,7 +118,7 @@ def verifica_sessao_iniciada(request, spk):
sessao = SessaoPlenaria.objects.get(id=spk)
if not sessao.iniciada or sessao.finalizada:
msg = _('Não é possível abrir matérias para votação. '\
msg = _('Não é possível abrir matérias para votação. '
'Esta Sessão Plenária não foi iniciada ou está finalizada.')
messages.add_message(request, messages.INFO, msg)
return False
@ -2455,6 +2456,8 @@ class PesquisarSessaoPlenariaView(FilterView):
numero_res=len(self.object_list)
)
context['show_results'] = show_results_filter_set(self.request.GET.copy())
return self.render_to_response(context)

4
sapl/templates/base/RelatorioHistoricoTramitacao_filter.html

@ -3,11 +3,11 @@
{% load crispy_forms_tags %}
{% block base_content %}
{% if not filter_url %}
{% if not show_results %}
{% crispy filter.form %}
{% endif %}
{% if filter_url %}
{% if show_results %}
<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>

4
sapl/templates/base/RelatorioMateriasPorAnoAutorTipo_filter.html

@ -3,11 +3,11 @@
{% load crispy_forms_tags %}
{% block base_content %}
{% if not filter_url %}
{% if not show_results %}
{% crispy filter.form %}
{% endif %}
{% if filter_url %}
{% if show_results %}
<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>

4
sapl/templates/base/RelatorioMateriasPorAutor_filter.html

@ -3,11 +3,11 @@
{% load crispy_forms_tags %}
{% block base_content %}
{% if not filter_url %}
{% if not show_results %}
{% crispy filter.form %}
{% endif %}
{% if filter_url %}
{% if show_results %}
<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>

4
sapl/templates/base/RelatorioPresencaSessao_filter.html

@ -4,11 +4,11 @@
{% load common_tags %}
{% block base_content %}
{% if not filter_url %}
{% if not show_results %}
{% crispy filter.form %}
{% endif %}
{% if filter_url %}
{% if show_results %}
<style type="text/css">
.presenca_table td, th{
text-align: center;

4
sapl/templates/materia/em_lote/acessorio.html

@ -3,11 +3,11 @@
{% block actions %}{% endblock %}
{% block detail_content %}
{% if not filter_url %}
{% if not show_results %}
{% crispy filter.form %}
{% endif %}
{% if filter_url %}
{% if show_results %}
{% if object_list.count > 0 %}
{% if object_list.count == 1 %}
<h3 style="text-align: right;">{% trans 'Pesquisa concluída com sucesso! Foi encontrada 1 matéria.'%}</h3>

4
sapl/templates/materia/em_lote/tramitacao.html

@ -3,11 +3,11 @@
{% block actions %}{% endblock %}
{% block detail_content %}
{% if not filter_url %}
{% if not show_results %}
{% crispy filter.form %}
{% endif %}
{% if filter_url %}
{% if show_results %}
{% if object_list|length > 0 %}
{% if object_list|length == 1 %}
<h3 style="text-align: right;">{% trans 'Pesquisa concluída com sucesso! Foi encontrada 1 matéria.'%}</h3>

6
sapl/templates/materia/materialegislativa_filter.html

@ -13,18 +13,18 @@
{% blocktrans with verbose_name=view.verbose_name %} Adicionar Matéria Legislativa {% endblocktrans %}
</a>
{% endif %}
{% if filter_url %}
{% if show_results %}
<a href="{% url 'sapl.materia:pesquisar_materia' %}" class="btn btn-default">{% trans 'Fazer nova pesquisa' %}</a>
{% endif %}
</div>
{% endblock %}
{% block detail_content %}
{% if not filter_url %}
{% if not show_results %}
{% crispy filter.form %}
{% endif %}
{% if filter_url %}
{% if show_results %}
<table class="table table-striped table-bordered">
<thead class="thead-default">
<tr><td><h3>{% trans "Resultados" %}</h3></td></tr>

6
sapl/templates/norma/normajuridica_filter.html

@ -14,7 +14,7 @@
{% blocktrans with verbose_name=view.verbose_name %} Adicionar Norma Jurídica {% endblocktrans %}
</a>
{% endif %}
{% if filter_url %}
{% if show_results %}
<a href="{% url 'sapl.norma:norma_pesquisa' %}" class="btn btn-default">{% trans 'Fazer nova pesquisa' %}</a>
{% endif %}
</div>
@ -22,11 +22,11 @@
{% endblock %}
{% block detail_content %}
{% if not filter_url %}
{% if not show_results %}
{% crispy filter.form %}
{% endif %}
{% if filter_url %}
{% if show_results %}
{% if page_obj|length %}
<br />
{% if page_obj|length > 1 %}

6
sapl/templates/protocoloadm/documentoadministrativo_filter.html

@ -13,7 +13,7 @@
</a>
{% endif %}
</div>
{% if filter_url %}
{% if show_results %}
<div class="actions btn-group pull-right" role="group">
<a href="{% url 'sapl.protocoloadm:pesq_doc_adm' %}" class="btn btn-default">{% trans 'Fazer Nova Pesquisa' %}</a>
</div>
@ -21,9 +21,9 @@
{% endblock actions %}
{% block detail_content %}
{% if not filter_url %} {% crispy filter.form %} {% endif %}
{% if not show_results %} {% crispy filter.form %} {% endif %}
{% if filter_url %}
{% if show_results %}
<table class="table table-striped table-bordered">
<thead class="thead-default"><tr><td><h3>Resultados</h3></td></tr></thead>
{% if page_obj|length %}

8
sapl/templates/protocoloadm/protocolo_filter.html

@ -8,7 +8,7 @@
{{ block.super }}
{% if filter_url %}
{% if show_results %}
<div class="actions btn-group pull-right grid-gutter-width-right " role="group">
<a href="{% url 'sapl.protocoloadm:protocolo' %}" class="btn btn-default">{% trans 'Fazer nova pesquisa' %}</a>
</div>
@ -19,15 +19,15 @@
{% block detail_content %}
<br>
{% if not filter_url %}
{% if not show_results %}
{% crispy filter.form %}
{% endif %}
{% if filter_url %}
{% if show_results %}
<table class="table table-striped table-bordered">
<thead class="thead-default"><tr><td><h3>Resultados</h3></td></tr></thead>
{% if page_obj|length %}
{% if filter_url %}
{% if show_results %}
{% if numero_res > 1 %}
<h3>Pesquisa concluída com sucesso! Foram encontrados {{numero_res}} protocolos.</h3>
{% elif numero_res == 1 %}

2
sapl/templates/sessao/sessaoplenaria_filter.html

@ -15,7 +15,7 @@
{% block detail_content %}
{% crispy filter.form %}
{% if filter_url %}
{% if show_results %}
<p></p>
<table class="table table-striped table-hover">
<thead class="thead-default"><tr><td><h3>Resultados</h3></td></tr></thead>

9
sapl/utils.py

@ -642,3 +642,12 @@ def parlamentares_ativos(data_inicio, data_fim=None):
flat=True).distinct('parlamentar_id')
return Parlamentar.objects.filter(id__in=parlamentares_id)
def show_results_filter_set(qr):
query_params = set(qr.keys())
if ((len(query_params) == 1 and 'iframe' in query_params) or
len(query_params) == 0):
return False
return True

Loading…
Cancel
Save