Browse Source

Conserta PEP8

pull/1478/head
Eduardo Calil 8 years ago
parent
commit
5300403afd
  1. 12
      sapl/base/views.py
  2. 1
      sapl/materia/tests/test_materia.py
  3. 6
      sapl/materia/tests/test_materia_form.py
  4. 4
      sapl/materia/urls.py
  5. 24
      sapl/materia/views.py
  6. 2
      sapl/norma/views.py
  7. 5
      sapl/parlamentares/views.py
  8. 4
      sapl/protocoloadm/views.py
  9. 5
      sapl/sessao/urls.py
  10. 8
      sapl/sessao/views.py

12
sapl/base/views.py

@ -205,7 +205,7 @@ class RelatorioAtasView(FilterView):
query_params = set(qr.keys()) query_params = set(qr.keys())
if ((len(query_params) == 1 and 'iframe' in query_params) or if ((len(query_params) == 1 and 'iframe' in query_params) or
len(query_params) == 0): len(query_params) == 0):
context['show_results'] = False context['show_results'] = False
else: else:
context['show_results'] = True context['show_results'] = True
@ -305,7 +305,7 @@ class RelatorioPresencaSessaoView(FilterView):
query_params = set(qr.keys()) query_params = set(qr.keys())
if ((len(query_params) == 1 and 'iframe' in query_params) or if ((len(query_params) == 1 and 'iframe' in query_params) or
len(query_params) == 0): len(query_params) == 0):
context['show_results'] = False context['show_results'] = False
else: else:
context['show_results'] = True context['show_results'] = True
@ -327,7 +327,7 @@ class RelatorioHistoricoTramitacaoView(FilterView):
query_params = set(qr.keys()) query_params = set(qr.keys())
if ((len(query_params) == 1 and 'iframe' in query_params) or if ((len(query_params) == 1 and 'iframe' in query_params) or
len(query_params) == 0): len(query_params) == 0):
context['show_results'] = False context['show_results'] = False
else: else:
context['show_results'] = True context['show_results'] = True
@ -363,7 +363,7 @@ class RelatorioMateriasTramitacaoView(FilterView):
query_params = set(qr.keys()) query_params = set(qr.keys())
if ((len(query_params) == 1 and 'iframe' in query_params) or if ((len(query_params) == 1 and 'iframe' in query_params) or
len(query_params) == 0): len(query_params) == 0):
context['show_results'] = False context['show_results'] = False
else: else:
context['show_results'] = True context['show_results'] = True
@ -442,7 +442,7 @@ class RelatorioMateriasPorAnoAutorTipoView(FilterView):
query_params = set(qr.keys()) query_params = set(qr.keys())
if ((len(query_params) == 1 and 'iframe' in query_params) or if ((len(query_params) == 1 and 'iframe' in query_params) or
len(query_params) == 0): len(query_params) == 0):
context['show_results'] = False context['show_results'] = False
else: else:
context['show_results'] = True context['show_results'] = True
@ -487,7 +487,7 @@ class RelatorioMateriasPorAutorView(FilterView):
query_params = set(qr.keys()) query_params = set(qr.keys())
if ((len(query_params) == 1 and 'iframe' in query_params) or if ((len(query_params) == 1 and 'iframe' in query_params) or
len(query_params) == 0): len(query_params) == 0):
context['show_results'] = False context['show_results'] = False
else: else:
context['show_results'] = True context['show_results'] = True

1
sapl/materia/tests/test_materia.py

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

6
sapl/materia/tests/test_materia_form.py

@ -3,7 +3,8 @@ from django.utils.translation import ugettext as _
from model_mommy import mommy from model_mommy import mommy
from sapl.materia import forms 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) @pytest.mark.django_db(transaction=False)
def test_valida_campos_obrigatorios_ficha_pesquisa_form(): def test_valida_campos_obrigatorios_ficha_pesquisa_form():
@ -19,6 +20,7 @@ def test_valida_campos_obrigatorios_ficha_pesquisa_form():
assert len(errors) == 3 assert len(errors) == 3
@pytest.mark.django_db(transaction=False) @pytest.mark.django_db(transaction=False)
def test_ficha_pesquisa_form_datas_invalidas(): def test_ficha_pesquisa_form_datas_invalidas():
tipo = mommy.make(TipoMateriaLegislativa) tipo = mommy.make(TipoMateriaLegislativa)
@ -29,7 +31,7 @@ def test_ficha_pesquisa_form_datas_invalidas():
}) })
assert not form.is_valid() assert not form.is_valid()
assert form.errors['__all__'] == [_('A Data Final não pode ser menor que ' assert form.errors['__all__'] == [_('A Data Final não pode ser menor que '
'a Data Inicial')] 'a Data Inicial')]
@pytest.mark.django_db(transaction=False) @pytest.mark.django_db(transaction=False)

4
sapl/materia/urls.py

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

24
sapl/materia/views.py

@ -14,7 +14,7 @@ from django.core.urlresolvers import reverse
from django.http import HttpResponse, JsonResponse from django.http import HttpResponse, JsonResponse
from django.http.response import Http404, HttpResponseRedirect from django.http.response import Http404, HttpResponseRedirect
from django.shortcuts import get_object_or_404, redirect 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 import formats
from django.utils.translation import ugettext_lazy as _ from django.utils.translation import ugettext_lazy as _
from django.views.generic import CreateView, ListView, TemplateView, UpdateView from django.views.generic import CreateView, ListView, TemplateView, UpdateView
@ -141,7 +141,7 @@ class AdicionarVariasAutorias(PermissionRequiredForAppCrudMixin, FilterView):
query_params = set(qr.keys()) query_params = set(qr.keys())
if ((len(query_params) == 1 and 'iframe' in query_params) or if ((len(query_params) == 1 and 'iframe' in query_params) or
len(query_params) == 0): len(query_params) == 0):
context['show_results'] = False context['show_results'] = False
else: else:
context['show_results'] = True context['show_results'] = True
@ -1517,7 +1517,7 @@ class MateriaLegislativaPesquisaView(FilterView):
query_params = set(qr.keys()) query_params = set(qr.keys())
if ((len(query_params) == 1 and 'iframe' in query_params) or if ((len(query_params) == 1 and 'iframe' in query_params) or
len(query_params) == 0): len(query_params) == 0):
context['show_results'] = False context['show_results'] = False
else: else:
context['show_results'] = True context['show_results'] = True
@ -1626,7 +1626,7 @@ class DocumentoAcessorioEmLoteView(PermissionRequiredMixin, FilterView):
query_params = set(qr.keys()) query_params = set(qr.keys())
if ((len(query_params) == 1 and 'iframe' in query_params) or if ((len(query_params) == 1 and 'iframe' in query_params) or
len(query_params) == 0): len(query_params) == 0):
context['show_results'] = False context['show_results'] = False
else: else:
context['show_results'] = True context['show_results'] = True
@ -1701,7 +1701,7 @@ class PrimeiraTramitacaoEmLoteView(PermissionRequiredMixin, FilterView):
query_params = set(qr.keys()) query_params = set(qr.keys())
if ((len(query_params) == 1 and 'iframe' in query_params) or if ((len(query_params) == 1 and 'iframe' in query_params) or
len(query_params) == 0): len(query_params) == 0):
context['show_results'] = False context['show_results'] = False
else: else:
context['show_results'] = True context['show_results'] = True
@ -1848,6 +1848,7 @@ class FichaPesquisaView(PermissionRequiredMixin, FormView):
return HttpResponseRedirect(url) return HttpResponseRedirect(url)
class FichaSelecionaView(PermissionRequiredMixin, FormView): class FichaSelecionaView(PermissionRequiredMixin, FormView):
form_class = FichaSelecionaForm form_class = FichaSelecionaForm
template_name = 'materia/impressos/ficha_seleciona.html' template_name = 'materia/impressos/ficha_seleciona.html'
@ -1856,7 +1857,7 @@ class FichaSelecionaView(PermissionRequiredMixin, FormView):
def get_context_data(self, **kwargs): def get_context_data(self, **kwargs):
if ('tipo' not in self.request.GET or if ('tipo' not in self.request.GET or
'data_inicial' not in self.request.GET or 'data_inicial' not in self.request.GET or
'data_final' not in self.request.GET): 'data_final' not in self.request.GET):
return HttpResponseRedirect(reverse( return HttpResponseRedirect(reverse(
'sapl.materia:impressos_ficha_pesquisa')) 'sapl.materia:impressos_ficha_pesquisa'))
@ -1875,13 +1876,14 @@ class FichaSelecionaView(PermissionRequiredMixin, FormView):
context['quantidade'] = len(materia_list) context['quantidade'] = len(materia_list)
materia_list = materia_list[:20] 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: if context['quantidade'] > 20:
messages.info(self.request, _('Sua pesquisa retornou mais do que ' messages.info(self.request, _('Sua pesquisa retornou mais do que '
'20 impressos. Por questões de performance, foram retornados ' '20 impressos. Por questões de performance, foram retornados '
'apenas os 20 primeiros. Caso queira outros, tente fazer uma ' 'apenas os 20 primeiros. Caso queira outros, tente fazer uma '
'pesquisa mais específica')) 'pesquisa mais específica'))
return context return context
@ -1899,6 +1901,6 @@ class FichaSelecionaView(PermissionRequiredMixin, FormView):
context['materia'] = materia context['materia'] = materia
context['despachos'] = materia.despachoinicial_set.all().values_list( context['despachos'] = materia.despachoinicial_set.all().values_list(
'comissao__nome', flat=True) 'comissao__nome', flat=True)
return gerar_pdf_impressos(self.request, context, 'materia/impressos/ficha_pdf.html') return gerar_pdf_impressos(self.request, context, 'materia/impressos/ficha_pdf.html')

2
sapl/norma/views.py

@ -83,7 +83,7 @@ class NormaPesquisaView(FilterView):
query_params = set(qr.keys()) query_params = set(qr.keys())
if ((len(query_params) == 1 and 'iframe' in query_params) or if ((len(query_params) == 1 and 'iframe' in query_params) or
len(query_params) == 0): len(query_params) == 0):
context['show_results'] = False context['show_results'] = False
else: else:
context['show_results'] = True context['show_results'] = True

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.parlamentares.apps import AppConfig
from sapl.utils import parlamentares_ativos from sapl.utils import parlamentares_ativos
from .forms import (FiliacaoForm, LegislaturaForm, from .forms import (FiliacaoForm, LegislaturaForm, MandatoForm,
MandatoForm, ParlamentarCreateForm, ParlamentarForm, ParlamentarCreateForm, ParlamentarForm, VotanteForm)
VotanteForm)
from .models import (CargoMesa, Coligacao, ComposicaoColigacao, ComposicaoMesa, from .models import (CargoMesa, Coligacao, ComposicaoColigacao, ComposicaoMesa,
Dependente, Filiacao, Frente, Legislatura, Mandato, Dependente, Filiacao, Frente, Legislatura, Mandato,
NivelInstrucao, Parlamentar, Partido, SessaoLegislativa, NivelInstrucao, Parlamentar, Partido, SessaoLegislativa,

4
sapl/protocoloadm/views.py

@ -215,7 +215,7 @@ class ProtocoloPesquisaView(PermissionRequiredMixin, FilterView):
qr = self.request.GET.copy() qr = self.request.GET.copy()
query_params = set(qr.keys()) query_params = set(qr.keys())
if ((len(query_params) == 1 and 'iframe' in query_params) or if ((len(query_params) == 1 and 'iframe' in query_params) or
len(query_params) == 0): len(query_params) == 0):
context['show_results'] = False context['show_results'] = False
else: else:
context['show_results'] = True context['show_results'] = True
@ -575,7 +575,7 @@ class PesquisarDocumentoAdministrativoView(DocumentoAdministrativoMixin,
qr = self.request.GET.copy() qr = self.request.GET.copy()
query_params = set(qr.keys()) query_params = set(qr.keys())
if ((len(query_params) == 1 and 'iframe' in query_params) or if ((len(query_params) == 1 and 'iframe' in query_params) or
len(query_params) == 0): len(query_params) == 0):
context['show_results'] = False context['show_results'] = False
else: else:
context['show_results'] = True context['show_results'] = True

5
sapl/sessao/urls.py

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

8
sapl/sessao/views.py

@ -117,7 +117,7 @@ def verifica_sessao_iniciada(request, spk):
sessao = SessaoPlenaria.objects.get(id=spk) sessao = SessaoPlenaria.objects.get(id=spk)
if not sessao.iniciada or sessao.finalizada: 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.') 'Esta Sessão Plenária não foi iniciada ou está finalizada.')
messages.add_message(request, messages.INFO, msg) messages.add_message(request, messages.INFO, msg)
return False return False
@ -143,8 +143,8 @@ def abrir_votacao(request, pk, spk):
raise Http404 raise Http404
if (verifica_presenca(request, presenca_model, spk) and if (verifica_presenca(request, presenca_model, spk) and
verifica_votacoes_abertas(request) and verifica_votacoes_abertas(request) and
verifica_sessao_iniciada(request, spk)): verifica_sessao_iniciada(request, spk)):
materia_votacao = model.objects.get(id=pk) materia_votacao = model.objects.get(id=pk)
materia_votacao.votacao_aberta = True materia_votacao.votacao_aberta = True
materia_votacao.save() materia_votacao.save()
@ -2458,7 +2458,7 @@ class PesquisarSessaoPlenariaView(FilterView):
qr = self.request.GET.copy() qr = self.request.GET.copy()
query_params = set(qr.keys()) query_params = set(qr.keys())
if ((len(query_params) == 1 and 'iframe' in query_params) or if ((len(query_params) == 1 and 'iframe' in query_params) or
len(query_params) == 0): len(query_params) == 0):
context['show_results'] = False context['show_results'] = False
else: else:
context['show_results'] = True context['show_results'] = True

Loading…
Cancel
Save