Browse Source

Corrige erros de PEP 8

pull/1416/head
Mariana Mendes 7 years ago
parent
commit
b4ba735fda
  1. 8
      create_admin.py
  2. 4
      genkey.py
  3. 2
      sapl/api/forms.py
  4. 2
      sapl/api/views.py
  5. 1
      sapl/base/templatetags/common_tags.py
  6. 8
      sapl/base/tests/teststub_urls.py
  7. 3
      sapl/base/views.py
  8. 4
      sapl/legacy/migracao_documentos.py
  9. 5
      sapl/legacy/migration.py
  10. 3
      sapl/legacy/scripts/street_sweeper.py
  11. 7
      sapl/materia/forms.py
  12. 1
      sapl/materia/urls.py
  13. 10
      sapl/materia/views.py
  14. 3
      sapl/norma/apps.py
  15. 3
      sapl/norma/signals.py
  16. 5
      sapl/painel/views.py
  17. 7
      sapl/protocoloadm/views.py
  18. 5
      sapl/relatorios/views.py
  19. 2
      sapl/sessao/forms.py
  20. 12
      sapl/sessao/views.py
  21. 36
      sapl/test_urls.py
  22. 3
      sapl/urls.py
  23. 10
      sapl/utils.py

8
create_admin.py

@ -3,8 +3,6 @@ import sys
import django
from sapl import settings
os.environ.setdefault("DJANGO_SETTINGS_MODULE", "sapl.settings")
@ -17,12 +15,14 @@ def create_superuser():
email = os.environ['ADMIN_EMAIL'] if 'ADMIN_EMAIL' in os.environ else ''
if User.objects.filter(username=username).exists():
print("[SUPERUSER] User %s already exists. Exiting without change." % username)
print("[SUPERUSER] User %s already exists."
" Exiting without change." % username)
sys.exit('ADMIN_USER_EXISTS')
else:
if not password:
print(
"[SUPERUSER] Environment variable $ADMIN_PASSWORD for user %s was not set. Leaving..." % username)
"[SUPERUSER] Environment variable $ADMIN_PASSWORD"
" for user %s was not set. Leaving..." % username)
sys.exit('MISSING_ADMIN_PASSWORD')
print("[SUPERUSER] Creating superuser...")

4
genkey.py

@ -2,7 +2,9 @@ import random
def generate_secret():
return ''.join([random.SystemRandom().choice('abcdefghijklmnopqrstuvwxyz0123456789!@#$%^&*(-_=+)') for i in range(50)])
return (''.join([random.SystemRandom().choice(
'abcdefghijklmnopqrst'
'uvwxyz0123456789!@#$%^&*(-_=+)') for i in range(50)]))
if __name__ == '__main__':
print(generate_secret())

2
sapl/api/forms.py

@ -1,4 +1,4 @@
from django.db.models import F, Q
from django.db.models import Q
from django.forms.fields import CharField, MultiValueField
from django.forms.widgets import MultiWidget, TextInput
from django.utils import timezone

2
sapl/api/views.py

@ -7,7 +7,7 @@ from rest_framework.generics import ListAPIView
from rest_framework.mixins import ListModelMixin, RetrieveModelMixin
from rest_framework.permissions import (AllowAny, IsAuthenticated,
IsAuthenticatedOrReadOnly)
from rest_framework.viewsets import GenericViewSet, ModelViewSet
from rest_framework.viewsets import GenericViewSet
from sapl.api.forms import (AutorChoiceFilterSet, AutoresPossiveisFilterSet,
AutorSearchForFieldFilterSet)

1
sapl/base/templatetags/common_tags.py

@ -4,6 +4,7 @@ from django import template
from sapl.base.models import AppConfig
from sapl.materia.models import DocumentoAcessorio, MateriaLegislativa
from sapl.norma.models import NormaJuridica
from sapl.parlamentares import Filiacao
from sapl.utils import filiacao_data
register = template.Library()

8
sapl/base/tests/teststub_urls.py

@ -3,8 +3,6 @@ from django.views.generic.base import TemplateView
from sapl.urls import urlpatterns as original_patterns
urlpatterns = original_patterns + patterns('', url(r'^zzzz$',
TemplateView.as_view(
template_name='index.html'),
name='zzzz')
)
urlpatterns = original_patterns + patterns
('', url(r'^zzzz$', TemplateView.as_view(
template_name='index.html'), name='zzzz'))

3
sapl/base/views.py

@ -7,7 +7,7 @@ from django.contrib.auth.tokens import default_token_generator
from django.core.exceptions import ObjectDoesNotExist
from django.core.mail import send_mail
from django.core.urlresolvers import reverse
from django.db.models import Count, Q
from django.db.models import Count
from django.http import HttpResponseRedirect
from django.utils.encoding import force_bytes
from django.utils.http import urlsafe_base64_decode, urlsafe_base64_encode
@ -20,7 +20,6 @@ from sapl.base.forms import AutorForm, AutorFormForAdmin, TipoAutorForm
from sapl.base.models import Autor, TipoAutor
from sapl.crud.base import CrudAux
from sapl.materia.models import MateriaLegislativa, TipoMateriaLegislativa
from sapl.parlamentares.models import Parlamentar
from sapl.sessao.models import (PresencaOrdemDia, SessaoPlenaria,
SessaoPlenariaPresenca)
from sapl.utils import parlamentares_ativos, sapl_logger

4
sapl/legacy/migracao_documentos.py

@ -3,7 +3,6 @@ import os
import re
import magic
from django.db.models.signals import post_delete, post_save
from sapl.base.models import CasaLegislativa
from sapl.materia.models import (DocumentoAcessorio, MateriaLegislativa,
@ -86,7 +85,8 @@ DOCS = {
DocumentoAcessorioAdministrativo: [(
'arquivo',
'administrativo/{}',
'private/documentoacessorioadministrativo/{0}/{0}_acessorio_administrativo{1}')
'private/documentoacessorioadministrativo/{0}/'
'{0}_acessorio_administrativo{1}')
],
}

5
sapl/legacy/migration.py

@ -14,15 +14,12 @@ from django.core.exceptions import ObjectDoesNotExist
from django.db import OperationalError, ProgrammingError, connections, models
from django.db.models import CharField, Count, Max, ProtectedError, TextField
from django.db.models.base import ModelBase
from django.db.models.signals import post_delete, post_save
from model_mommy import mommy
from model_mommy.mommy import foreign_key_required, make
from sapl.base.models import Argumento, Autor, Constraint, ProblemaMigracao
from sapl.comissoes.models import Comissao, Composicao, Participacao
from sapl.legacy.models import Protocolo as ProtocoloLegado
from sapl.materia.models import (AcompanhamentoMateria, DocumentoAcessorio,
MateriaLegislativa, Proposicao,
from sapl.materia.models import (AcompanhamentoMateria, Proposicao,
StatusTramitacao, TipoDocumento,
TipoMateriaLegislativa, TipoProposicao,
Tramitacao)

3
sapl/legacy/scripts/street_sweeper.py

@ -12,7 +12,8 @@ DB = ''
SELECT_EXCLUIDOS = "SELECT %s FROM %s WHERE ind_excluido = 1 ORDER BY %s"
REGISTROS_INCONSISTENTES = "DELETE FROM %s WHERE %s in (%s) AND ind_excluido = 0 "
REGISTROS_INCONSISTENTES = "DELETE FROM %s WHERE %s "
"in (%s) AND ind_excluido = 0 "
EXCLUI_REGISTRO = "DELETE FROM %s WHERE ind_excluido=1"

7
sapl/materia/forms.py

@ -493,9 +493,10 @@ class MateriaLegislativaFilterSet(django_filters.FilterSet):
autoria__autor = django_filters.CharFilter(widget=forms.HiddenInput())
autoria__primeiro_autor = django_filters.BooleanFilter(required=False,
label='Primeiro Autor',
widget=forms.HiddenInput())
autoria__primeiro_autor = django_filters.BooleanFilter(
required=False,
label='Primeiro Autor',
widget=forms.HiddenInput())
ementa = django_filters.CharFilter(lookup_expr='icontains')

1
sapl/materia/urls.py

@ -23,7 +23,6 @@ from sapl.materia.views import (AcompanhamentoConfirmarView,
TramitacaoEmLoteView, UnidadeTramitacaoCrud,
proposicao_texto, recuperar_materia)
from . import receivers
from .apps import AppConfig
app_name = AppConfig.name

10
sapl/materia/views.py

@ -4,14 +4,11 @@ from string import ascii_letters, digits
from crispy_forms.helper import FormHelper
from crispy_forms.layout import HTML
from django import forms
from django.contrib import messages
from django.contrib.auth.decorators import permission_required
from django.contrib.auth.mixins import PermissionRequiredMixin
from django.contrib.contenttypes.models import ContentType
from django.core.exceptions import MultipleObjectsReturned, ObjectDoesNotExist
from django.core.exceptions import ObjectDoesNotExist
from django.core.urlresolvers import reverse
from django.db.models import Q
from django.http import HttpResponse, JsonResponse
from django.http.response import Http404, HttpResponseRedirect
from django.shortcuts import get_object_or_404, redirect
@ -1735,9 +1732,8 @@ class TramitacaoEmLoteView(PrimeiraTramitacaoEmLoteView):
if ('tramitacao__status' in qr and
'tramitacao__unidade_tramitacao_destino' in qr and
qr['tramitacao__status'] and
qr['tramitacao__unidade_tramitacao_destino']
):
qr['tramitacao__status'] and
qr['tramitacao__unidade_tramitacao_destino']):
lista = filtra_tramitacao_destino_and_status(
qr['tramitacao__status'],
qr['tramitacao__unidade_tramitacao_destino'])

3
sapl/norma/apps.py

@ -6,6 +6,3 @@ class AppConfig(apps.AppConfig):
name = 'sapl.norma'
label = 'norma'
verbose_name = _('Norma Jurídica')
def ready(self):
from . import signals

3
sapl/norma/signals.py

@ -1,3 +0,0 @@
from django.db.models.signals import post_delete, post_save
from .models import NormaJuridica

5
sapl/painel/views.py

@ -1,8 +1,8 @@
from datetime import date
from django.contrib import messages
from django.contrib.auth.decorators import user_passes_test
from django.core.exceptions import MultipleObjectsReturned, ObjectDoesNotExist
from django.core.exceptions import ObjectDoesNotExist
from django.core.urlresolvers import reverse
from django.db.models import Q
from django.http import HttpResponse, JsonResponse
@ -12,7 +12,6 @@ from django.utils.translation import ugettext_lazy as _
from sapl.crud.base import Crud
from sapl.painel.apps import AppConfig
from sapl.painel.models import Painel
from sapl.parlamentares.models import Filiacao, Votante
from sapl.sessao.models import (ExpedienteMateria, OrdemDia, PresencaOrdemDia,
RegistroVotacao, SessaoPlenaria,

7
sapl/protocoloadm/views.py

@ -7,11 +7,10 @@ from django.contrib.contenttypes.models import ContentType
from django.core.exceptions import ObjectDoesNotExist
from django.core.urlresolvers import reverse
from django.db.models import Max, Q
from django.http import (Http404, HttpResponse, HttpResponseRedirect,
JsonResponse)
from django.http import Http404, HttpResponse, JsonResponse
from django.shortcuts import redirect
from django.utils.translation import ugettext_lazy as _
from django.views.generic import CreateView, DetailView, FormView, ListView
from django.views.generic import CreateView, DetailView, ListView
from django.views.generic.base import TemplateView
from django_filters.views import FilterView
@ -20,7 +19,7 @@ from sapl.base.models import Autor
from sapl.comissoes.models import Comissao
from sapl.crud.base import Crud, CrudAux, MasterDetailCrud, make_pagination
from sapl.materia.models import MateriaLegislativa, TipoMateriaLegislativa
from sapl.parlamentares.models import Parlamentar
from sapl.parlamentares.models import Legislatura, Parlamentar
from sapl.protocoloadm.models import Protocolo
from sapl.utils import create_barcode, get_client_ip

5
sapl/relatorios/views.py

@ -15,9 +15,8 @@ from sapl.protocoloadm.models import (DocumentoAdministrativo, Protocolo,
TramitacaoAdministrativo)
from sapl.sessao.models import (ExpedienteMateria, ExpedienteSessao,
IntegranteMesa, Orador, OradorExpediente,
OrdemDia, PresencaOrdemDia, RegistroVotacao,
SessaoPlenaria, SessaoPlenariaPresenca,
TipoExpediente)
OrdemDia, PresencaOrdemDia, SessaoPlenaria,
SessaoPlenariaPresenca)
from sapl.settings import STATIC_ROOT
from sapl.utils import UF, filiacao_data

2
sapl/sessao/forms.py

@ -79,7 +79,7 @@ class SessaoPlenariaForm(ModelForm):
if qtd_sessoes > 0:
if instance.pk: # update
if not instance.pk in sessoes or qtd_sessoes > 1:
if instance.pk not in sessoes or qtd_sessoes > 1:
raise error
else: # create
raise error

12
sapl/sessao/views.py

@ -173,7 +173,8 @@ class MateriaOrdemDiaCrud(MasterDetailCrud):
self.initial['data_ordem'] = SessaoPlenaria.objects.get(
pk=self.kwargs['pk']).data_inicio.strftime('%d/%m/%Y')
max_numero_ordem = OrdemDia.objects.filter(
sessao_plenaria=self.kwargs['pk']).aggregate(Max('numero_ordem'))['numero_ordem__max']
sessao_plenaria=(self.kwargs['pk']).
aggregate(Max('numero_ordem'))['numero_ordem__max'])
self.initial['numero_ordem'] = (
max_numero_ordem if max_numero_ordem else 0) + 1
return self.initial
@ -424,7 +425,8 @@ class ExpedienteMateriaCrud(MasterDetailCrud):
self.initial['data_ordem'] = SessaoPlenaria.objects.get(
pk=self.kwargs['pk']).data_inicio.strftime('%d/%m/%Y')
max_numero_ordem = ExpedienteMateria.objects.filter(
sessao_plenaria=self.kwargs['pk']).aggregate(Max('numero_ordem'))['numero_ordem__max']
sessao_plenaria=(self.kwargs['pk']).
aggregate(Max('numero_ordem'))['numero_ordem__max'])
self.initial['numero_ordem'] = (
max_numero_ordem if max_numero_ordem else 0) + 1
return self.initial
@ -1257,7 +1259,8 @@ class ResumoView(DetailView):
# =====================================================================
# Oradores nas Explicações Pessoais
oradores_explicacoes = []
for orador in Orador.objects.filter(sessao_plenaria_id=self.object.id).order_by('numero_ordem'):
for orador in Orador.objects.filter(
sessao_plenaria_id=self.object.id).order_by('numero_ordem'):
for parlamentar in Parlamentar.objects.filter(
id=orador.parlamentar.id):
partido_sigla = Filiacao.objects.filter(
@ -2171,7 +2174,8 @@ class VotacaoExpedienteEditView(SessaoPermissionMixin):
expediente_id = kwargs['oid']
if(int(request.POST['anular_votacao']) == 1):
for r in RegistroVotacao.objects.filter(expediente_id=expediente_id):
for r in RegistroVotacao.objects.filter(
expediente_id=expediente_id):
r.delete()
expediente = ExpedienteMateria.objects.get(

36
sapl/test_urls.py

@ -174,24 +174,24 @@ apps_url_patterns_prefixs_and_users = {
]},
'redireciona_urls': {
'prefixs': [
'/default_index_html',
'/consultas/parlamentar/parlamentar_',
'/consultas/comissao/comissao_',
'/consultas/pauta_sessao/pauta_sessao_',
'/consultas/sessao_plenaria/',
'/relatorios_administrativos/relatorios_administrativos_index_html',
'/tramitacaoMaterias/tramitacaoMaterias',
'/tramitacaoMaterias/materia_mostrar_proc',
'/generico/materia_pesquisar_',
'/consultas/mesa_diretora/mesa_diretora_index_html',
'/consultas/mesa_diretora/parlamentar/parlamentar_',
'/generico/norma_juridica_pesquisar_',
'/consultas/norma_juridica/norma_juridica_mostrar_proc',
'/historicoTramitacoes/historicoTramitacoes',
'/atasSessao',
'/presencaSessao',
'/resumoPropositurasAutor',
'/propositurasAnoAutorTipo',
'/default_index_html',
'/consultas/parlamentar/parlamentar_',
'/consultas/comissao/comissao_',
'/consultas/pauta_sessao/pauta_sessao_',
'/consultas/sessao_plenaria/',
'/relatorios_administrativos/relatorios_administrativos_index_html',
'/tramitacaoMaterias/tramitacaoMaterias',
'/tramitacaoMaterias/materia_mostrar_proc',
'/generico/materia_pesquisar_',
'/consultas/mesa_diretora/mesa_diretora_index_html',
'/consultas/mesa_diretora/parlamentar/parlamentar_',
'/generico/norma_juridica_pesquisar_',
'/consultas/norma_juridica/norma_juridica_mostrar_proc',
'/historicoTramitacoes/historicoTramitacoes',
'/atasSessao',
'/presencaSessao',
'/resumoPropositurasAutor',
'/propositurasAnoAutorTipo',
]},
'lexml': {
'prefixs': [

3
sapl/urls.py

@ -35,7 +35,8 @@ import sapl.relatorios.urls
import sapl.sessao.urls
urlpatterns = [
url(r'^$', TemplateView.as_view(template_name='index.html'), name='sapl_index'),
url(r'^$', TemplateView.as_view(template_name='index.html'),
name='sapl_index'),
url(r'^message$', TemplateView.as_view(template_name='base.html')),
url(r'^admin/', include(admin.site.urls)),

10
sapl/utils.py

@ -4,8 +4,6 @@ import os
import re
from datetime import date
from functools import wraps
from subprocess import PIPE, call
from threading import Thread
from unicodedata import normalize as unicodedata_normalize
import django_filters
@ -27,7 +25,7 @@ from floppyforms import ClearableFileInput
from reversion.admin import VersionAdmin
from sapl.crispy_layout_mixin import SaplFormLayout, form_actions, to_row
from sapl.settings import BASE_DIR, PROJECT_DIR
from sapl.settings import BASE_DIR
sapl_logger = logging.getLogger(BASE_DIR.name)
@ -541,10 +539,12 @@ def texto_upload_path(instance, filename, subpath='', pk_first=False):
if isinstance(instance, (DocumentoAdministrativo, Proposicao)):
prefix = 'private'
str_path = './sapl/%(prefix)s/%(model_name)s/%(subpath)s/%(pk)s/%(filename)s'
str_path = ('./sapl/%(prefix)s/%(model_name)s/'
'%(subpath)s/%(pk)s/%(filename)s')
if pk_first:
str_path = './sapl/%(prefix)s/%(model_name)s/%(pk)s/%(subpath)s/%(filename)s'
str_path = ('./sapl/%(prefix)s/%(model_name)s/'
'%(pk)s/%(subpath)s/%(filename)s')
path = str_path %\
{

Loading…
Cancel
Save