diff --git a/create_admin.py b/create_admin.py index 6b3d52709..6080fbd07 100644 --- a/create_admin.py +++ b/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...") diff --git a/genkey.py b/genkey.py index 248a67e8f..207989e92 100644 --- a/genkey.py +++ b/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()) diff --git a/sapl/api/forms.py b/sapl/api/forms.py index f8ad6fee7..e9900e0c0 100644 --- a/sapl/api/forms.py +++ b/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 diff --git a/sapl/api/views.py b/sapl/api/views.py index 1eccaf5ef..2909d5a0a 100644 --- a/sapl/api/views.py +++ b/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) diff --git a/sapl/base/templatetags/common_tags.py b/sapl/base/templatetags/common_tags.py index 928aeab5d..9f306d833 100644 --- a/sapl/base/templatetags/common_tags.py +++ b/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() diff --git a/sapl/base/tests/teststub_urls.py b/sapl/base/tests/teststub_urls.py index a105489c7..e81cbdb59 100644 --- a/sapl/base/tests/teststub_urls.py +++ b/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')) diff --git a/sapl/base/views.py b/sapl/base/views.py index f8c0832cf..b2ce6ad50 100644 --- a/sapl/base/views.py +++ b/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 diff --git a/sapl/legacy/migracao_documentos.py b/sapl/legacy/migracao_documentos.py index ea29a9072..2e514942b 100644 --- a/sapl/legacy/migracao_documentos.py +++ b/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}') ], } diff --git a/sapl/legacy/migration.py b/sapl/legacy/migration.py index 791e6a7b5..7b31f00f9 100644 --- a/sapl/legacy/migration.py +++ b/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) diff --git a/sapl/legacy/scripts/street_sweeper.py b/sapl/legacy/scripts/street_sweeper.py index a33710b1a..d01fd3b52 100644 --- a/sapl/legacy/scripts/street_sweeper.py +++ b/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" diff --git a/sapl/materia/forms.py b/sapl/materia/forms.py index 21d1845d8..f8aa30ea5 100644 --- a/sapl/materia/forms.py +++ b/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') diff --git a/sapl/materia/urls.py b/sapl/materia/urls.py index 2cbb3a62b..e91505c24 100644 --- a/sapl/materia/urls.py +++ b/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 diff --git a/sapl/materia/views.py b/sapl/materia/views.py index c7c1e2618..9182a220f 100644 --- a/sapl/materia/views.py +++ b/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']) diff --git a/sapl/norma/apps.py b/sapl/norma/apps.py index c4d55ade0..effd4f271 100644 --- a/sapl/norma/apps.py +++ b/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 diff --git a/sapl/norma/signals.py b/sapl/norma/signals.py index 4a5472715..e69de29bb 100644 --- a/sapl/norma/signals.py +++ b/sapl/norma/signals.py @@ -1,3 +0,0 @@ -from django.db.models.signals import post_delete, post_save - -from .models import NormaJuridica diff --git a/sapl/painel/views.py b/sapl/painel/views.py index 13ee7883b..3183c61db 100644 --- a/sapl/painel/views.py +++ b/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, diff --git a/sapl/protocoloadm/views.py b/sapl/protocoloadm/views.py index 4e7a946c6..fe2390a8c 100644 --- a/sapl/protocoloadm/views.py +++ b/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 diff --git a/sapl/relatorios/views.py b/sapl/relatorios/views.py index 28e012817..b40372d3f 100644 --- a/sapl/relatorios/views.py +++ b/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 diff --git a/sapl/sessao/forms.py b/sapl/sessao/forms.py index a1f65e960..150922f18 100644 --- a/sapl/sessao/forms.py +++ b/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 diff --git a/sapl/sessao/views.py b/sapl/sessao/views.py index 3e47a6da4..e29a9ee5e 100644 --- a/sapl/sessao/views.py +++ b/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( diff --git a/sapl/test_urls.py b/sapl/test_urls.py index 8b5207276..9daa58fab 100644 --- a/sapl/test_urls.py +++ b/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': [ diff --git a/sapl/urls.py b/sapl/urls.py index 91d3adeb6..38667b4e7 100644 --- a/sapl/urls.py +++ b/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)), diff --git a/sapl/utils.py b/sapl/utils.py index 90581bd99..7c5e1697e 100644 --- a/sapl/utils.py +++ b/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 %\ {