From 3b7f768c29907a135cae15b766765527621d6d39 Mon Sep 17 00:00:00 2001 From: Marcio Mazza Date: Mon, 12 Mar 2018 13:21:19 -0300 Subject: [PATCH] Conserta PEP 8 --- sapl/api/forms.py | 1 + sapl/api/serializers.py | 1 + sapl/api/urls.py | 1 + sapl/api/views.py | 1 + sapl/base/admin.py | 1 + sapl/base/forms.py | 36 +++++++------ sapl/base/search_indexes.py | 3 +- sapl/base/templatetags/common_tags.py | 3 +- sapl/base/templatetags/menus.py | 4 +- sapl/base/tests/test_form.py | 1 + sapl/base/tests/teststub_urls.py | 1 + sapl/base/urls.py | 9 ++-- sapl/base/views.py | 16 ++++-- sapl/comissoes/forms.py | 1 + sapl/comissoes/models.py | 2 +- sapl/comissoes/tests/test_comissoes.py | 1 + sapl/comissoes/urls.py | 4 +- sapl/comissoes/views.py | 23 ++++----- sapl/compilacao/apps.py | 6 +-- sapl/compilacao/forms.py | 1 + sapl/compilacao/models.py | 2 +- .../templatetags/compilacao_filters.py | 1 + .../tests/test_tipo_texto_articulado_form.py | 2 +- sapl/compilacao/urls.py | 11 ++-- sapl/compilacao/views.py | 9 ++-- sapl/crispy_layout_mixin.py | 2 +- sapl/crud/base.py | 3 +- sapl/crud/tests/test_base.py | 1 + .../commands/migracao_documentos.py | 1 + .../scripts/exporta_zope/exporta_zope.py | 1 + sapl/legacy/scripts/scrap_original_forms.py | 2 +- sapl/legacy/scripts/study.py | 1 + sapl/legacy/test_migration.py | 2 +- sapl/lexml/urls.py | 1 + sapl/materia/admin.py | 5 +- sapl/materia/email_utils.py | 1 + sapl/materia/forms.py | 13 ++--- sapl/materia/models.py | 2 +- sapl/materia/receivers.py | 1 + sapl/materia/tests/test_email_templates.py | 1 + sapl/materia/tests/test_materia.py | 50 +++++++++---------- sapl/materia/tests/test_materia_form.py | 1 + sapl/materia/urls.py | 3 +- sapl/materia/views.py | 5 +- sapl/norma/forms.py | 1 + sapl/norma/tests/test_norma.py | 1 + sapl/norma/urls.py | 1 + sapl/norma/views.py | 1 + sapl/painel/views.py | 1 + sapl/parlamentares/forms.py | 1 + sapl/parlamentares/models.py | 1 + sapl/parlamentares/tests/test_mandato.py | 1 + .../parlamentares/tests/test_parlamentares.py | 1 + sapl/parlamentares/urls.py | 1 + sapl/parlamentares/views.py | 3 +- sapl/protocoloadm/forms.py | 15 +++--- sapl/protocoloadm/models.py | 1 + sapl/protocoloadm/tests/test_protocoloadm.py | 1 + sapl/protocoloadm/urls.py | 1 + sapl/protocoloadm/views.py | 3 +- sapl/redireciona_urls/views.py | 2 + sapl/relatorios/views.py | 7 ++- sapl/rules/apps.py | 1 + sapl/rules/tests/test_rules.py | 1 + sapl/sessao/forms.py | 1 + sapl/sessao/tests/test_sessao_view.py | 1 + sapl/sessao/urls.py | 1 + sapl/sessao/views.py | 3 +- sapl/test_crispy_layout_mixin.py | 1 + sapl/test_urls.py | 5 +- sapl/urls.py | 13 ++--- sapl/utils.py | 13 +++-- scripts/anonimizador/anon.py | 1 + ...onvert_null_to_empty_in_all_char_fields.py | 1 + scripts/fk_protocoloadm_docadm.py | 1 + 75 files changed, 189 insertions(+), 134 deletions(-) diff --git a/sapl/api/forms.py b/sapl/api/forms.py index 2ee441d34..94bc80de4 100644 --- a/sapl/api/forms.py +++ b/sapl/api/forms.py @@ -7,6 +7,7 @@ from django_filters.filters import DateFilter, MethodFilter, ModelChoiceFilter from rest_framework import serializers from rest_framework.compat import django_filters from rest_framework.filters import FilterSet + from sapl.base.models import Autor, TipoAutor from sapl.parlamentares.models import Legislatura from sapl.utils import generic_relations_for_model diff --git a/sapl/api/serializers.py b/sapl/api/serializers.py index 9e08ea991..9219bf0e4 100644 --- a/sapl/api/serializers.py +++ b/sapl/api/serializers.py @@ -1,4 +1,5 @@ from rest_framework import serializers + from sapl.base.models import Autor, CasaLegislativa from sapl.materia.models import MateriaLegislativa from sapl.sessao.models import OrdemDia, SessaoPlenaria diff --git a/sapl/api/urls.py b/sapl/api/urls.py index 005a71f5c..1f19e9d1f 100644 --- a/sapl/api/urls.py +++ b/sapl/api/urls.py @@ -1,6 +1,7 @@ from django.conf import settings from django.conf.urls import include, url from rest_framework.routers import DefaultRouter + from sapl.api.views import (AutoresPossiveisListView, AutoresProvaveisListView, AutorListView, MateriaLegislativaViewSet, ModelChoiceView, SessaoPlenariaViewSet) diff --git a/sapl/api/views.py b/sapl/api/views.py index 2adffa7e5..9853e6af0 100644 --- a/sapl/api/views.py +++ b/sapl/api/views.py @@ -8,6 +8,7 @@ from rest_framework.mixins import ListModelMixin, RetrieveModelMixin from rest_framework.permissions import (AllowAny, IsAuthenticated, IsAuthenticatedOrReadOnly) from rest_framework.viewsets import GenericViewSet + from sapl.api.forms import (AutorChoiceFilterSet, AutoresPossiveisFilterSet, AutorSearchForFieldFilterSet) from sapl.api.serializers import (AutorChoiceSerializer, AutorSerializer, diff --git a/sapl/base/admin.py b/sapl/base/admin.py index 00f9e104b..2f7cd0ed4 100644 --- a/sapl/base/admin.py +++ b/sapl/base/admin.py @@ -3,6 +3,7 @@ from django.core.urlresolvers import reverse from django.shortcuts import redirect from django.utils.translation import ugettext_lazy as _ from reversion.models import Revision + from sapl.base.models import ProblemaMigracao from sapl.utils import register_all_models_in_admin diff --git a/sapl/base/forms.py b/sapl/base/forms.py index 1b86c519c..092d93b59 100644 --- a/sapl/base/forms.py +++ b/sapl/base/forms.py @@ -13,16 +13,17 @@ from django.db import models, transaction from django.forms import Form, ModelForm from django.utils.translation import ugettext_lazy as _ from django.utils.translation import string_concat + from sapl.base.models import Autor, TipoAutor from sapl.crispy_layout_mixin import (SaplFormLayout, form_actions, to_column, to_row) from sapl.materia.models import MateriaLegislativa from sapl.sessao.models import SessaoPlenaria from sapl.settings import MAX_IMAGE_UPLOAD_SIZE -from sapl.utils import (RANGE_ANOS, ChoiceWithoutValidationField, - ImageThumbnailFileInput, RangeWidgetOverride, - autor_label, autor_modal, models_with_gr_for_model, - qs_override_django_filter, YES_NO_CHOICES) +from sapl.utils import (RANGE_ANOS, YES_NO_CHOICES, + ChoiceWithoutValidationField, ImageThumbnailFileInput, + RangeWidgetOverride, autor_label, autor_modal, + models_with_gr_for_model, qs_override_django_filter) from .models import AppConfig, CasaLegislativa @@ -40,8 +41,10 @@ STATUS_USER_CHOICE = [ ('X', _('Excluir Usuário')), ] + def get_roles(): - return [(g.id, g.name) for g in Group.objects.all().order_by('name')] + return [(g.id, g.name) for g in Group.objects.all().order_by('name')] + class UsuarioCreateForm(ModelForm): @@ -50,16 +53,18 @@ class UsuarioCreateForm(ModelForm): lastname = forms.CharField(required=True, label="Sobrenome") password1 = forms.CharField(required=True, widget=forms.PasswordInput, label='Senha') password2 = forms.CharField(required=True, widget=forms.PasswordInput, label='Confirmar senha') - user_active = forms.ChoiceField(required=False, choices=YES_NO_CHOICES, label="Usuário ativo?", initial='True') + user_active = forms.ChoiceField(required=False, choices=YES_NO_CHOICES, + label="Usuário ativo?", initial='True') #ROLES = [(g.id, g.name) for g in Group.objects.all().order_by('name')] - roles = forms.MultipleChoiceField(required=True, widget=forms.CheckboxSelectMultiple(), choices=get_roles) + roles = forms.MultipleChoiceField( + required=True, widget=forms.CheckboxSelectMultiple(), choices=get_roles) class Meta: model = get_user_model() - fields = ['username', 'firstname', 'lastname', 'email', 'password1', 'password2', 'user_active', 'roles'] - + fields = ['username', 'firstname', 'lastname', 'email', + 'password1', 'password2', 'user_active', 'roles'] def clean(self): super(UsuarioCreateForm, self).clean() @@ -69,7 +74,7 @@ class UsuarioCreateForm(ModelForm): data = self.cleaned_data if data['password1'] != data['password2']: - raise ValidationError('Senhas informadas são diferentes') + raise ValidationError('Senhas informadas são diferentes') def __init__(self, *args, **kwargs): @@ -97,6 +102,7 @@ class UsuarioCreateForm(ModelForm): 'roles', row4) + class UsuarioEditForm(ModelForm): # ROLES = [(g.id, g.name) for g in Group.objects.all().order_by('name')] @@ -104,8 +110,10 @@ class UsuarioEditForm(ModelForm): password1 = forms.CharField(required=False, widget=forms.PasswordInput, label='Senha') password2 = forms.CharField(required=False, widget=forms.PasswordInput, label='Confirmar senha') - user_active = forms.ChoiceField(choices=YES_NO_CHOICES, required=True, label="Usuário ativo?", initial='True') - roles = forms.MultipleChoiceField(required=True, widget=forms.CheckboxSelectMultiple(), choices=get_roles) + user_active = forms.ChoiceField(choices=YES_NO_CHOICES, required=True, + label="Usuário ativo?", initial='True') + roles = forms.MultipleChoiceField( + required=True, widget=forms.CheckboxSelectMultiple(), choices=get_roles) class Meta: model = get_user_model() @@ -121,7 +129,6 @@ class UsuarioEditForm(ModelForm): [('password1', 6), ('password2', 6)]) - row3 = to_row([(form_actions(label='Salvar Alterações'), 6)]) self.helper = FormHelper() @@ -139,7 +146,7 @@ class UsuarioEditForm(ModelForm): data = self.cleaned_data if data['password1'] and data['password1'] != data['password2']: - raise ValidationError('Senhas informadas são diferentes') + raise ValidationError('Senhas informadas são diferentes') class TipoAutorForm(ModelForm): @@ -572,6 +579,7 @@ class RelatorioHistoricoTramitacaoFilterSet(django_filters.FilterSet): form_actions(label='Pesquisar')) ) + class RelatorioDataFimPrazoTramitacaoFilterSet(django_filters.FilterSet): filter_overrides = {models.DateField: { diff --git a/sapl/base/search_indexes.py b/sapl/base/search_indexes.py index 3deb42eac..f685cb002 100644 --- a/sapl/base/search_indexes.py +++ b/sapl/base/search_indexes.py @@ -13,13 +13,14 @@ from haystack.constants import Indexable from haystack.fields import CharField from haystack.indexes import SearchIndex from haystack.utils import get_model_ct_tuple +from textract.exceptions import ExtensionNotSupported + from sapl.compilacao.models import (STATUS_TA_IMMUTABLE_PUBLIC, STATUS_TA_PUBLIC, Dispositivo, TextoArticulado) from sapl.materia.models import DocumentoAcessorio, MateriaLegislativa from sapl.norma.models import NormaJuridica from sapl.settings import BASE_DIR, SOLR_URL -from textract.exceptions import ExtensionNotSupported logger = logging.getLogger(BASE_DIR.name) diff --git a/sapl/base/templatetags/common_tags.py b/sapl/base/templatetags/common_tags.py index 00ab405cf..9e095f072 100644 --- a/sapl/base/templatetags/common_tags.py +++ b/sapl/base/templatetags/common_tags.py @@ -1,11 +1,12 @@ from compressor.utils import get_class from django import template +from django.template.defaultfilters import stringfilter + from sapl.base.models import AppConfig from sapl.materia.models import DocumentoAcessorio, MateriaLegislativa from sapl.norma.models import NormaJuridica from sapl.parlamentares.models import Filiacao from sapl.utils import filiacao_data -from django.template.defaultfilters import stringfilter register = template.Library() diff --git a/sapl/base/templatetags/menus.py b/sapl/base/templatetags/menus.py index 92df1e39f..f90a6940f 100644 --- a/sapl/base/templatetags/menus.py +++ b/sapl/base/templatetags/menus.py @@ -1,9 +1,9 @@ +import yaml from django import template from django.core.urlresolvers import reverse from django.utils.translation import ugettext_lazy as _ -import yaml -from sapl.utils import sapl_logger +from sapl.utils import sapl_logger register = template.Library() diff --git a/sapl/base/tests/test_form.py b/sapl/base/tests/test_form.py index fcaecdaaf..35f1c82bf 100644 --- a/sapl/base/tests/test_form.py +++ b/sapl/base/tests/test_form.py @@ -1,5 +1,6 @@ import pytest from django.utils.translation import ugettext_lazy as _ + from sapl.base.forms import CasaLegislativaForm diff --git a/sapl/base/tests/teststub_urls.py b/sapl/base/tests/teststub_urls.py index 3d85e2d9b..9796768f2 100644 --- a/sapl/base/tests/teststub_urls.py +++ b/sapl/base/tests/teststub_urls.py @@ -1,5 +1,6 @@ from django.conf.urls import patterns, url from django.views.generic.base import TemplateView + from sapl.urls import urlpatterns as original_patterns ptrn = patterns('', diff --git a/sapl/base/urls.py b/sapl/base/urls.py index e1e2e1c00..0f720071f 100644 --- a/sapl/base/urls.py +++ b/sapl/base/urls.py @@ -5,20 +5,21 @@ from django.contrib.auth.views import (password_reset, password_reset_complete, password_reset_confirm, password_reset_done) from django.views.generic.base import TemplateView + from sapl.base.views import AutorCrud, ConfirmarEmailView, TipoAutorCrud from sapl.settings import EMAIL_SEND_USER from .apps import AppConfig from .forms import LoginForm, NovaSenhaForm, RecuperarSenhaForm from .views import (AlterarSenha, AppConfigCrud, CasaLegislativaCrud, - HelpTopicView, RelatorioAtasView, + CreateUsuarioView, DeleteUsuarioView, EditUsuarioView, + HelpTopicView, ListarUsuarioView, RelatorioAtasView, + RelatorioDataFimPrazoTramitacaoView, RelatorioHistoricoTramitacaoView, RelatorioMateriasPorAnoAutorTipoView, RelatorioMateriasPorAutorView, RelatorioMateriasTramitacaoView, - RelatorioPresencaSessaoView, SaplSearchView, - RelatorioDataFimPrazoTramitacaoView, ListarUsuarioView, EditUsuarioView, CreateUsuarioView, - DeleteUsuarioView) + RelatorioPresencaSessaoView, SaplSearchView) app_name = AppConfig.name diff --git a/sapl/base/views.py b/sapl/base/views.py index e2bdcef3f..2240a71ba 100644 --- a/sapl/base/views.py +++ b/sapl/base/views.py @@ -14,13 +14,15 @@ from django.utils.encoding import force_bytes from django.utils.http import urlsafe_base64_decode, urlsafe_base64_encode from django.utils.translation import ugettext_lazy as _ from django.utils.translation import string_concat -from django.views.generic import FormView, ListView, DetailView, UpdateView, CreateView, DeleteView +from django.views.generic import (CreateView, DeleteView, DetailView, FormView, + ListView, UpdateView) from django.views.generic.base import TemplateView from django_filters.views import FilterView from haystack.views import SearchView + from sapl.base.forms import AutorForm, AutorFormForAdmin, TipoAutorForm from sapl.base.models import Autor, TipoAutor -from sapl.crud.base import (CrudAux, make_pagination) +from sapl.crud.base import CrudAux, make_pagination from sapl.materia.models import (Autoria, MateriaLegislativa, TipoMateriaLegislativa) from sapl.sessao.models import (PresencaOrdemDia, SessaoPlenaria, @@ -30,12 +32,13 @@ from sapl.utils import (parlamentares_ativos, sapl_logger, from .forms import (AlterarSenhaForm, CasaLegislativaForm, ConfiguracoesAppForm, RelatorioAtasFilterSet, + RelatorioDataFimPrazoTramitacaoFilterSet, RelatorioHistoricoTramitacaoFilterSet, RelatorioMateriasPorAnoAutorTipoFilterSet, RelatorioMateriasPorAutorFilterSet, RelatorioMateriasTramitacaoilterSet, - RelatorioPresencaSessaoFilterSet, - RelatorioDataFimPrazoTramitacaoFilterSet, UsuarioEditForm, UsuarioCreateForm) + RelatorioPresencaSessaoFilterSet, UsuarioCreateForm, + UsuarioEditForm) from .models import AppConfig, CasaLegislativa @@ -70,6 +73,7 @@ class TipoAutorCrud(CrudAux): return vn class ListView(CrudAux.ListView): + def get_queryset(self): qs = CrudAux.ListView.get_queryset(self) qs = qs.filter(content_type__isnull=True) @@ -84,6 +88,7 @@ class TipoAutorCrud(CrudAux): return context class TipoAutorMixin: + def dispatch(self, request, *args, **kwargs): object = self.get_object() if object.content_type: @@ -359,6 +364,7 @@ class RelatorioHistoricoTramitacaoView(FilterView): return context + class RelatorioDataFimPrazoTramitacaoView(FilterView): model = MateriaLegislativa filterset_class = RelatorioDataFimPrazoTramitacaoFilterSet @@ -569,6 +575,7 @@ class CreateUsuarioView(PermissionRequiredMixin, CreateView): return HttpResponseRedirect(self.get_success_url()) + class DeleteUsuarioView(PermissionRequiredMixin, DeleteView): model = get_user_model() @@ -585,7 +592,6 @@ class DeleteUsuarioView(PermissionRequiredMixin, DeleteView): return qs.filter(id=self.kwargs['pk']) - class EditUsuarioView(PermissionRequiredMixin, UpdateView): model = get_user_model() form_class = UsuarioEditForm diff --git a/sapl/comissoes/forms.py b/sapl/comissoes/forms.py index 33be2003d..ea27eab0d 100644 --- a/sapl/comissoes/forms.py +++ b/sapl/comissoes/forms.py @@ -5,6 +5,7 @@ from django.db import transaction from django.db.models import Q from django.forms import ModelForm from django.utils.translation import ugettext_lazy as _ + from sapl.base.models import Autor, TipoAutor from sapl.comissoes.models import Comissao, Composicao, Participacao, Reuniao from sapl.parlamentares.models import Legislatura, Mandato, Parlamentar diff --git a/sapl/comissoes/models.py b/sapl/comissoes/models.py index 882fe8638..2a5bd489c 100644 --- a/sapl/comissoes/models.py +++ b/sapl/comissoes/models.py @@ -1,7 +1,7 @@ +import reversion from django.db import models from django.utils.translation import ugettext_lazy as _ from model_utils import Choices -import reversion from sapl.base.models import Autor from sapl.parlamentares.models import Parlamentar diff --git a/sapl/comissoes/tests/test_comissoes.py b/sapl/comissoes/tests/test_comissoes.py index 0b040b914..fee303192 100644 --- a/sapl/comissoes/tests/test_comissoes.py +++ b/sapl/comissoes/tests/test_comissoes.py @@ -1,6 +1,7 @@ import pytest from django.core.urlresolvers import reverse from model_mommy import mommy + from sapl.comissoes.models import Comissao, Composicao, Periodo, TipoComissao from sapl.parlamentares.models import Filiacao, Parlamentar, Partido diff --git a/sapl/comissoes/urls.py b/sapl/comissoes/urls.py index 47fb0b059..4bf1904aa 100644 --- a/sapl/comissoes/urls.py +++ b/sapl/comissoes/urls.py @@ -1,7 +1,9 @@ from django.conf.urls import include, url + from sapl.comissoes.views import (CargoCrud, ComissaoCrud, ComposicaoCrud, MateriasTramitacaoListView, ParticipacaoCrud, - PeriodoComposicaoCrud, ReuniaoCrud, TipoComissaoCrud) + PeriodoComposicaoCrud, ReuniaoCrud, + TipoComissaoCrud) from .apps import AppConfig diff --git a/sapl/comissoes/views.py b/sapl/comissoes/views.py index 0fd5a2c13..8324f4b6a 100644 --- a/sapl/comissoes/views.py +++ b/sapl/comissoes/views.py @@ -7,19 +7,17 @@ from django.views.generic.base import RedirectView from django.views.generic.detail import DetailView from django.views.generic.edit import FormMixin - from sapl.base.models import AppConfig as AppsAppConfig -from sapl.crud.base import (RP_DETAIL, RP_LIST, Crud, - CrudAux, MasterDetailCrud, - PermissionRequiredForAppCrudMixin) +from sapl.comissoes.apps import AppConfig from sapl.comissoes.forms import ParticipacaoCreateForm, ParticipacaoEditForm +from sapl.crud.base import (RP_DETAIL, RP_LIST, Crud, CrudAux, + MasterDetailCrud, + PermissionRequiredForAppCrudMixin) from sapl.materia.models import MateriaLegislativa, Tramitacao -from .forms import ReuniaoForm, ComissaoForm - +from .forms import ComissaoForm, ReuniaoForm from .models import (CargoComissao, Comissao, Composicao, Participacao, - Periodo, TipoComissao, Reuniao) -from sapl.comissoes.apps import AppConfig + Periodo, Reuniao, TipoComissao) def pegar_url_composicao(pk): @@ -60,6 +58,7 @@ class ParticipacaoCrud(MasterDetailCrud): form_class = ParticipacaoEditForm class DeleteView(MasterDetailCrud.DeleteView): + def get_success_url(self): composicao_comissao_pk = self.object.composicao.comissao.pk composicao_pk = self.object.composicao.pk @@ -147,6 +146,7 @@ class MateriasTramitacaoListView(ListView): context['object'] = Comissao.objects.get(id=self.kwargs['pk']) return context + class ReuniaoCrud(MasterDetailCrud): model = Reuniao parent_field = 'comissao' @@ -168,20 +168,17 @@ class ReuniaoCrud(MasterDetailCrud): def get_initial(self): return {'comissao': self.object.comissao} - class CreateView(MasterDetailCrud.CreateView): form_class = ReuniaoForm def get_initial(self): - comissao = Comissao.objects.get(id=self.kwargs['pk']) - - return {'comissao': comissao} + comissao = Comissao.objects.get(id=self.kwargs['pk']) + return {'comissao': comissao} class DeleteView(MasterDetailCrud.DeleteView): pass - class DetailView(MasterDetailCrud.DetailView): @xframe_options_exempt diff --git a/sapl/compilacao/apps.py b/sapl/compilacao/apps.py index 6b96175b5..96bd10b87 100644 --- a/sapl/compilacao/apps.py +++ b/sapl/compilacao/apps.py @@ -2,10 +2,10 @@ import logging from django import apps from django.conf import settings -from django.db import models, connection +from django.db import connection, models from django.db.utils import DEFAULT_DB_ALIAS, IntegrityError -from django.utils.translation import ugettext_lazy as _, string_concat - +from django.utils.translation import ugettext_lazy as _ +from django.utils.translation import string_concat from sapl.settings import BASE_DIR diff --git a/sapl/compilacao/forms.py b/sapl/compilacao/forms.py index 0748b1423..f51504f2c 100644 --- a/sapl/compilacao/forms.py +++ b/sapl/compilacao/forms.py @@ -14,6 +14,7 @@ from django.forms.forms import Form from django.forms.models import ModelForm from django.template import defaultfilters from django.utils.translation import ugettext_lazy as _ + from sapl import utils from sapl.compilacao.models import (NOTAS_PUBLICIDADE_CHOICES, PARTICIPACAO_SOCIAL_CHOICES, Dispositivo, diff --git a/sapl/compilacao/models.py b/sapl/compilacao/models.py index ec420c135..ad30cc23c 100644 --- a/sapl/compilacao/models.py +++ b/sapl/compilacao/models.py @@ -1,4 +1,5 @@ +import reversion from django.contrib import messages from django.contrib.contenttypes.fields import GenericForeignKey from django.contrib.contenttypes.models import ContentType @@ -12,7 +13,6 @@ from django.utils import timezone from django.utils.decorators import classonlymethod from django.utils.encoding import force_text from django.utils.translation import ugettext_lazy as _ -import reversion from sapl.compilacao.utils import (get_integrations_view_names, int_to_letter, int_to_roman) diff --git a/sapl/compilacao/templatetags/compilacao_filters.py b/sapl/compilacao/templatetags/compilacao_filters.py index 58c6dfaec..e56478bae 100644 --- a/sapl/compilacao/templatetags/compilacao_filters.py +++ b/sapl/compilacao/templatetags/compilacao_filters.py @@ -4,6 +4,7 @@ from django.core.signing import Signer from django.db.models import Q from django.utils.safestring import mark_safe from django.utils.translation import ugettext_lazy as _ + from sapl.compilacao.models import Dispositivo register = template.Library() diff --git a/sapl/compilacao/tests/test_tipo_texto_articulado_form.py b/sapl/compilacao/tests/test_tipo_texto_articulado_form.py index b682307c9..6c64adc78 100644 --- a/sapl/compilacao/tests/test_tipo_texto_articulado_form.py +++ b/sapl/compilacao/tests/test_tipo_texto_articulado_form.py @@ -1,6 +1,6 @@ +import pytest from django.utils.translation import ugettext as _ from model_mommy import mommy -import pytest from sapl.compilacao import forms from sapl.compilacao.models import PerfilEstruturalTextoArticulado, TipoNota diff --git a/sapl/compilacao/urls.py b/sapl/compilacao/urls.py index decbd5578..7d4d58f0f 100644 --- a/sapl/compilacao/urls.py +++ b/sapl/compilacao/urls.py @@ -1,4 +1,5 @@ from django.conf.urls import include, url + from sapl.compilacao import views from sapl.compilacao.views import (TipoDispositivoCrud, TipoNotaCrud, TipoPublicacaoCrud, TipoVideCrud, @@ -116,13 +117,13 @@ urlpatterns = [ include(TipoDispositivoCrud.get_urls())), url(r'^sistema/ta/config/tipo-textoarticulado$', - views.TipoTaListView.as_view(), name='tipo_ta_list'), + views.TipoTaListView.as_view(), name='tipo_ta_list'), url(r'^sistema/ta/config/tipo-textoarticulado/create$', - views.TipoTaCreateView.as_view(), name='tipo_ta_create'), + views.TipoTaCreateView.as_view(), name='tipo_ta_create'), url(r'^sistema/ta/config/tipo-textoarticulado/(?P[0-9]+)$', - views.TipoTaDetailView.as_view(), name='tipo_ta_detail'), + views.TipoTaDetailView.as_view(), name='tipo_ta_detail'), url(r'^sistema/ta/config/tipo-textoarticulado/(?P[0-9]+)/edit$', - views.TipoTaUpdateView.as_view(), name='tipo_ta_edit'), + views.TipoTaUpdateView.as_view(), name='tipo_ta_edit'), url(r'^sistema/ta/config/tipo-textoarticulado/(?P[0-9]+)/delete$', - views.TipoTaDeleteView.as_view(), name='tipo_ta_delete'), + views.TipoTaDeleteView.as_view(), name='tipo_ta_delete'), ] diff --git a/sapl/compilacao/views.py b/sapl/compilacao/views.py index 250ef70ea..78d1e221e 100644 --- a/sapl/compilacao/views.py +++ b/sapl/compilacao/views.py @@ -1,7 +1,7 @@ -from collections import OrderedDict -from datetime import timedelta import logging import sys +from collections import OrderedDict +from datetime import timedelta from braces.views import FormMessagesMixin from django import forms @@ -19,8 +19,8 @@ from django.http.response import (HttpResponse, HttpResponseRedirect, from django.shortcuts import get_object_or_404, redirect from django.utils.dateparse import parse_date from django.utils.encoding import force_text -from django.utils.translation import string_concat from django.utils.translation import ugettext_lazy as _ +from django.utils.translation import string_concat from django.views.generic.base import TemplateView from django.views.generic.detail import DetailView from django.views.generic.edit import (CreateView, DeleteView, FormView, @@ -48,10 +48,9 @@ from sapl.compilacao.models import (STATUS_TA_EDITION, STATUS_TA_PRIVATE, from sapl.compilacao.utils import (DISPOSITIVO_SELECT_RELATED, DISPOSITIVO_SELECT_RELATED_EDIT, get_integrations_view_names) -from sapl.crud.base import Crud, CrudListView, make_pagination, CrudAux +from sapl.crud.base import Crud, CrudAux, CrudListView, make_pagination from sapl.settings import BASE_DIR - TipoNotaCrud = CrudAux.build(TipoNota, 'tipo_nota') TipoVideCrud = CrudAux.build(TipoVide, 'tipo_vide') TipoPublicacaoCrud = CrudAux.build(TipoPublicacao, 'tipo_publicacao') diff --git a/sapl/crispy_layout_mixin.py b/sapl/crispy_layout_mixin.py index 0adc1c679..12a876b12 100644 --- a/sapl/crispy_layout_mixin.py +++ b/sapl/crispy_layout_mixin.py @@ -1,5 +1,6 @@ from math import ceil +import rtyaml from crispy_forms.bootstrap import FormActions from crispy_forms.helper import FormHelper from crispy_forms.layout import HTML, Div, Fieldset, Layout, Submit @@ -7,7 +8,6 @@ from django import template from django.core.urlresolvers import reverse, reverse_lazy from django.utils import formats from django.utils.translation import ugettext as _ -import rtyaml def heads_and_tails(list_of_lists): diff --git a/sapl/crud/base.py b/sapl/crud/base.py index 3f20e376b..8bb8c3794 100644 --- a/sapl/crud/base.py +++ b/sapl/crud/base.py @@ -17,8 +17,8 @@ from django.http.response import Http404 from django.shortcuts import redirect from django.utils.decorators import classonlymethod from django.utils.encoding import force_text -from django.utils.translation import string_concat from django.utils.translation import ugettext_lazy as _ +from django.utils.translation import string_concat from django.views.generic import (CreateView, DeleteView, DetailView, ListView, UpdateView) from django.views.generic.base import ContextMixin @@ -30,7 +30,6 @@ from sapl.rules.map_rules import (RP_ADD, RP_CHANGE, RP_DELETE, RP_DETAIL, from sapl.settings import BASE_DIR from sapl.utils import normalize - logger = logging.getLogger(BASE_DIR.name) ACTION_LIST, ACTION_CREATE, ACTION_DETAIL, ACTION_UPDATE, ACTION_DELETE = \ diff --git a/sapl/crud/tests/test_base.py b/sapl/crud/tests/test_base.py index 8a8a26af4..8e1d10965 100644 --- a/sapl/crud/tests/test_base.py +++ b/sapl/crud/tests/test_base.py @@ -1,6 +1,7 @@ import pytest from django.core.urlresolvers import reverse from model_mommy import mommy + from sapl.crud.base import (CrispyLayoutFormMixin, CrudListView, from_to, get_field_display, make_pagination) from sapl.crud.tests.stub_app.models import Continent, Country diff --git a/sapl/legacy/management/commands/migracao_documentos.py b/sapl/legacy/management/commands/migracao_documentos.py index f9e81a29c..7cba09d5a 100644 --- a/sapl/legacy/management/commands/migracao_documentos.py +++ b/sapl/legacy/management/commands/migracao_documentos.py @@ -1,4 +1,5 @@ from django.core.management.base import BaseCommand + from sapl.legacy.migracao_documentos import migrar_documentos diff --git a/sapl/legacy/scripts/exporta_zope/exporta_zope.py b/sapl/legacy/scripts/exporta_zope/exporta_zope.py index c097c1a1a..31c4c3188 100755 --- a/sapl/legacy/scripts/exporta_zope/exporta_zope.py +++ b/sapl/legacy/scripts/exporta_zope/exporta_zope.py @@ -14,6 +14,7 @@ from functools import partial import magic import yaml + import ZODB.DB import ZODB.FileStorage from ZODB.broken import Broken diff --git a/sapl/legacy/scripts/scrap_original_forms.py b/sapl/legacy/scripts/scrap_original_forms.py index a3325b32e..dbe8e4219 100644 --- a/sapl/legacy/scripts/scrap_original_forms.py +++ b/sapl/legacy/scripts/scrap_original_forms.py @@ -7,8 +7,8 @@ import pkg_resources import yaml from bs4 import BeautifulSoup from bs4.element import NavigableString, Tag - from django.apps.config import AppConfig + from sapl.crispy_layout_mixin import heads_and_tails from sapl.legacy.migracao import appconfs, get_renames from sapl.legacy.scripts.utils import getsourcelines diff --git a/sapl/legacy/scripts/study.py b/sapl/legacy/scripts/study.py index 1078af38e..9a4149fe5 100644 --- a/sapl/legacy/scripts/study.py +++ b/sapl/legacy/scripts/study.py @@ -1,4 +1,5 @@ from django.apps import apps + from sapl.legacy.migracao import legacy_app for model in apps.get_app_config('legacy').get_models(): diff --git a/sapl/legacy/test_migration.py b/sapl/legacy/test_migration.py index 53034987d..ad1ad86d3 100644 --- a/sapl/legacy/test_migration.py +++ b/sapl/legacy/test_migration.py @@ -1,7 +1,7 @@ from random import shuffle from .migracao import (_formatar_lista_para_sql, get_autorias_sem_repeticoes, - get_reapontamento_de_autores_repetidos) + get_reapontamento_de_autores_repetidos) def test_unifica_autores_repetidos_no_legado(): diff --git a/sapl/lexml/urls.py b/sapl/lexml/urls.py index a10299ca0..e7d582030 100644 --- a/sapl/lexml/urls.py +++ b/sapl/lexml/urls.py @@ -1,4 +1,5 @@ from django.conf.urls import include, url + from sapl.lexml.views import LexmlProvedorCrud, LexmlPublicadorCrud from .apps import AppConfig diff --git a/sapl/materia/admin.py b/sapl/materia/admin.py index 25c107378..6fb649296 100644 --- a/sapl/materia/admin.py +++ b/sapl/materia/admin.py @@ -4,11 +4,10 @@ from django.contrib import admin from sapl.base.models import TipoAutor from sapl.comissoes.models import TipoComissao from sapl.materia.models import Proposicao -from sapl.parlamentares.models import TipoAfastamento, SituacaoMilitar, \ - TipoDependente +from sapl.parlamentares.models import (SituacaoMilitar, TipoAfastamento, + TipoDependente) from sapl.utils import register_all_models_in_admin - register_all_models_in_admin(__name__) if not settings.DEBUG: diff --git a/sapl/materia/email_utils.py b/sapl/materia/email_utils.py index a28fcbc5f..3dc6b220d 100644 --- a/sapl/materia/email_utils.py +++ b/sapl/materia/email_utils.py @@ -4,6 +4,7 @@ from django.core.mail import EmailMultiAlternatives, get_connection, send_mail from django.core.urlresolvers import reverse from django.template import Context, loader from django.utils import timezone + from sapl.base.models import CasaLegislativa from sapl.settings import EMAIL_SEND_USER diff --git a/sapl/materia/forms.py b/sapl/materia/forms.py index 1eebd5c7d..a7cac7df5 100644 --- a/sapl/materia/forms.py +++ b/sapl/materia/forms.py @@ -1,7 +1,7 @@ import os + import django_filters -import sapl from crispy_forms.bootstrap import Alert, FormActions, InlineRadios from crispy_forms.helper import FormHelper from crispy_forms.layout import (HTML, Button, Column, Div, Field, Fieldset, @@ -22,7 +22,9 @@ from django.utils.encoding import force_text from django.utils.html import format_html from django.utils.safestring import mark_safe from django.utils.translation import ugettext_lazy as _ -from sapl.base.models import Autor, TipoAutor, AppConfig + +import sapl +from sapl.base.models import AppConfig, Autor, TipoAutor from sapl.comissoes.models import Comissao from sapl.compilacao.models import (STATUS_TA_IMMUTABLE_PUBLIC, STATUS_TA_PRIVATE) @@ -39,8 +41,8 @@ from sapl.settings import MAX_DOC_UPLOAD_SIZE from sapl.utils import (RANGE_ANOS, YES_NO_CHOICES, ChoiceWithoutValidationField, MateriaPesquisaOrderingFilter, RangeWidgetOverride, - autor_label, autor_modal, models_with_gr_for_model, - qs_override_django_filter, gerar_hash_arquivo) + autor_label, autor_modal, gerar_hash_arquivo, + models_with_gr_for_model, qs_override_django_filter) from .models import (AcompanhamentoMateria, Anexada, Autoria, DespachoInicial, DocumentoAcessorio, Numeracao, Proposicao, Relatoria, @@ -1135,7 +1137,7 @@ class ProposicaoForm(forms.ModelForm): widgets = { 'descricao': widgets.Textarea(attrs={'rows': 4}), 'tipo': TipoProposicaoSelect(), - 'hash_code': forms.HiddenInput(),} + 'hash_code': forms.HiddenInput(), } def __init__(self, *args, **kwargs): self.texto_articulado_proposicao = sapl.base.models.AppConfig.attr( @@ -1222,7 +1224,6 @@ class ProposicaoForm(forms.ModelForm): # FIXME hash para textos articulados inst.hash_code = 'P' + ta.hash() + '/' + str(inst.pk) - def clean(self): super(ProposicaoForm, self).clean() diff --git a/sapl/materia/models.py b/sapl/materia/models.py index 66fd94900..51fbcb855 100644 --- a/sapl/materia/models.py +++ b/sapl/materia/models.py @@ -10,7 +10,7 @@ from django.utils import formats, timezone from django.utils.translation import ugettext_lazy as _ from model_utils import Choices -from sapl.base.models import Autor, SEQUENCIA_NUMERACAO +from sapl.base.models import SEQUENCIA_NUMERACAO, Autor from sapl.comissoes.models import Comissao from sapl.compilacao.models import (PerfilEstruturalTextoArticulado, TextoArticulado) diff --git a/sapl/materia/receivers.py b/sapl/materia/receivers.py index 6e4ee737e..945c6636e 100644 --- a/sapl/materia/receivers.py +++ b/sapl/materia/receivers.py @@ -1,5 +1,6 @@ from django.db.models.signals import post_delete, post_save from django.dispatch import receiver + from sapl.materia.models import Tramitacao from sapl.materia.signals import tramitacao_signal from sapl.utils import get_base_url diff --git a/sapl/materia/tests/test_email_templates.py b/sapl/materia/tests/test_email_templates.py index 35b5f4ef2..aac13cbb7 100644 --- a/sapl/materia/tests/test_email_templates.py +++ b/sapl/materia/tests/test_email_templates.py @@ -1,4 +1,5 @@ from django.core import mail + from sapl.materia.email_utils import enviar_emails, load_email_templates diff --git a/sapl/materia/tests/test_materia.py b/sapl/materia/tests/test_materia.py index ff8f89ad6..4af9df7ea 100644 --- a/sapl/materia/tests/test_materia.py +++ b/sapl/materia/tests/test_materia.py @@ -1,12 +1,12 @@ import pytest -from django.db.models import Max from django.contrib.auth import get_user_model from django.contrib.contenttypes.models import ContentType from django.core.files.uploadedfile import SimpleUploadedFile from django.core.urlresolvers import reverse +from django.db.models import Max from model_mommy import mommy + from sapl.base.models import Autor, TipoAutor -from sapl.parlamentares.models import Legislatura from sapl.comissoes.models import Comissao, TipoComissao from sapl.materia.models import (Anexada, Autoria, DespachoInicial, DocumentoAcessorio, MateriaLegislativa, @@ -16,6 +16,7 @@ from sapl.materia.models import (Anexada, Autoria, DespachoInicial, Tramitacao, UnidadeTramitacao) from sapl.norma.models import (LegislacaoCitada, NormaJuridica, TipoNormaJuridica) +from sapl.parlamentares.models import Legislatura from sapl.utils import models_with_gr_for_model @@ -509,32 +510,30 @@ def test_form_errors_proposicao(admin_client): ['Este campo é obrigatório.']) - @pytest.mark.django_db(transaction=False) def test_numeracao_materia_legislativa_por_legislatura(admin_client): - #Criar Legislaturas + # Criar Legislaturas legislatura1 = mommy.make(Legislatura, - data_inicio='2014-01-01', - data_fim='2018-12-31', - numero=20, - data_eleicao='2013-10-15' - ) + data_inicio='2014-01-01', + data_fim='2018-12-31', + numero=20, + data_eleicao='2013-10-15' + ) legislatura2 = mommy.make(Legislatura, - data_inicio='2009-01-01', - data_fim='2013-12-31', - numero=21, - data_eleicao='2018-10-15' - ) - + data_inicio='2009-01-01', + data_fim='2013-12-31', + numero=21, + data_eleicao='2018-10-15' + ) # Cria uma materia na legislatura1 - tipo_materia = mommy.make(TipoMateriaLegislativa, id=1,sequencia_numeracao='L') + tipo_materia = mommy.make(TipoMateriaLegislativa, id=1, sequencia_numeracao='L') materia = mommy.make(MateriaLegislativa, - tipo=tipo_materia, - ano=2017, - numero=1 - ) + tipo=tipo_materia, + ano=2017, + numero=1 + ) url = reverse('sapl.materia:recuperar_materia') @@ -557,13 +556,12 @@ def test_numeracao_materia_legislativa_por_legislatura(admin_client): def test_numeracao_materia_legislativa_por_ano(admin_client): # Cria uma materia - tipo_materia = mommy.make(TipoMateriaLegislativa, id=1,sequencia_numeracao='A') + tipo_materia = mommy.make(TipoMateriaLegislativa, id=1, sequencia_numeracao='A') materia = mommy.make(MateriaLegislativa, - tipo=tipo_materia, - ano=2017, - numero=1 - ) - + tipo=tipo_materia, + ano=2017, + numero=1 + ) url = reverse('sapl.materia:recuperar_materia') diff --git a/sapl/materia/tests/test_materia_form.py b/sapl/materia/tests/test_materia_form.py index f94a6cb8d..41ad04837 100644 --- a/sapl/materia/tests/test_materia_form.py +++ b/sapl/materia/tests/test_materia_form.py @@ -1,6 +1,7 @@ import pytest from django.utils.translation import ugettext as _ from model_mommy import mommy + from sapl.materia import forms from sapl.materia.models import MateriaLegislativa, TipoMateriaLegislativa diff --git a/sapl/materia/urls.py b/sapl/materia/urls.py index 3a30800d2..934c4dbac 100644 --- a/sapl/materia/urls.py +++ b/sapl/materia/urls.py @@ -1,4 +1,5 @@ from django.conf.urls import include, url + from sapl.materia.views import (AcompanhamentoConfirmarView, AcompanhamentoExcluirView, AcompanhamentoMateriaView, AnexadaCrud, @@ -62,7 +63,7 @@ urlpatterns_materia = [ url(r'^materia/(?P[0-9]+)/create_simplificado$', CriarProtocoloMateriaView.as_view(), name='materia_create_simplificado'), - url(r'^materia/recuperar-materia',recuperar_materia, name='recuperar_materia'), + url(r'^materia/recuperar-materia', recuperar_materia, name='recuperar_materia'), url(r'^materia/(?P[0-9]+)/ta$', MateriaTaView.as_view(), name='materia_ta'), diff --git a/sapl/materia/views.py b/sapl/materia/views.py index ebbcca5e5..81a4dfcd1 100644 --- a/sapl/materia/views.py +++ b/sapl/materia/views.py @@ -2,6 +2,7 @@ from datetime import datetime from random import choice from string import ascii_letters, digits +import weasyprint from crispy_forms.helper import FormHelper from crispy_forms.layout import HTML from django.contrib import messages @@ -22,8 +23,8 @@ from django.views.generic import CreateView, ListView, TemplateView, UpdateView from django.views.generic.base import RedirectView from django.views.generic.edit import FormView from django_filters.views import FilterView -import weasyprint +import sapl from sapl.base.models import Autor, CasaLegislativa from sapl.comissoes.models import Comissao, Participacao from sapl.compilacao.models import (STATUS_TA_IMMUTABLE_RESTRICT, @@ -47,7 +48,6 @@ from sapl.utils import (TURNO_TRAMITACAO_CHOICES, YES_NO_CHOICES, autor_label, autor_modal, gerar_hash_arquivo, get_base_url, get_mime_type_from_file_extension, montar_row_autor, show_results_filter_set) -import sapl from .email_utils import do_envia_email_confirmacao from .forms import (AcessorioEmLoteFilterSet, AcompanhamentoMateriaForm, @@ -68,7 +68,6 @@ from .models import (AcompanhamentoMateria, Anexada, AssuntoMateria, Autoria, TipoProposicao, Tramitacao, UnidadeTramitacao) from .signals import tramitacao_signal - AssuntoMateriaCrud = CrudAux.build(AssuntoMateria, 'assunto_materia') OrigemCrud = CrudAux.build(Origem, '') diff --git a/sapl/norma/forms.py b/sapl/norma/forms.py index c9daaec9f..87a44d41f 100644 --- a/sapl/norma/forms.py +++ b/sapl/norma/forms.py @@ -8,6 +8,7 @@ from django.db import models from django.forms import ModelForm, widgets from django.utils import timezone from django.utils.translation import ugettext_lazy as _ + from sapl.crispy_layout_mixin import form_actions, to_row from sapl.materia.models import MateriaLegislativa, TipoMateriaLegislativa from sapl.settings import MAX_DOC_UPLOAD_SIZE diff --git a/sapl/norma/tests/test_norma.py b/sapl/norma/tests/test_norma.py index 8d40b7202..6603d7167 100644 --- a/sapl/norma/tests/test_norma.py +++ b/sapl/norma/tests/test_norma.py @@ -2,6 +2,7 @@ import pytest from django.core.urlresolvers import reverse from django.utils.translation import ugettext_lazy as _ from model_mommy import mommy + from sapl.materia.models import MateriaLegislativa, TipoMateriaLegislativa from sapl.norma.forms import (NormaJuridicaForm, NormaPesquisaSimplesForm, NormaRelacionadaForm) diff --git a/sapl/norma/urls.py b/sapl/norma/urls.py index 12ba05cba..93081c4fc 100644 --- a/sapl/norma/urls.py +++ b/sapl/norma/urls.py @@ -1,4 +1,5 @@ from django.conf.urls import include, url + from sapl.norma.views import (AssuntoNormaCrud, NormaCrud, NormaPesquisaView, NormaRelacionadaCrud, NormaTaView, TipoNormaCrud, TipoVinculoNormaJuridicaCrud, recuperar_norma, diff --git a/sapl/norma/views.py b/sapl/norma/views.py index 249d480b0..73e259a33 100644 --- a/sapl/norma/views.py +++ b/sapl/norma/views.py @@ -11,6 +11,7 @@ from django.views.generic import CreateView, ListView, TemplateView, UpdateView from django.views.generic.base import RedirectView from django.views.generic.edit import FormView from django_filters.views import FilterView + from sapl.base.models import AppConfig from sapl.compilacao.views import IntegracaoTaView from sapl.crud.base import (RP_DETAIL, RP_LIST, Crud, CrudAux, diff --git a/sapl/painel/views.py b/sapl/painel/views.py index 5acb06195..454b61d8e 100644 --- a/sapl/painel/views.py +++ b/sapl/painel/views.py @@ -11,6 +11,7 @@ from django.http.response import Http404, HttpResponseRedirect from django.shortcuts import render from django.utils import timezone from django.utils.translation import ugettext_lazy as _ + from sapl.base.models import AppConfig as ConfiguracoesAplicacao from sapl.base.models import CasaLegislativa from sapl.crud.base import Crud diff --git a/sapl/parlamentares/forms.py b/sapl/parlamentares/forms.py index 80c78cf82..a159ca233 100644 --- a/sapl/parlamentares/forms.py +++ b/sapl/parlamentares/forms.py @@ -14,6 +14,7 @@ from django.utils import timezone from django.utils.translation import ugettext_lazy as _ from floppyforms.widgets import ClearableFileInput from image_cropping.widgets import CropWidget, ImageCropWidget + from sapl.base.models import Autor, TipoAutor from sapl.crispy_layout_mixin import form_actions, to_row from sapl.rules import SAPL_GROUP_VOTANTE diff --git a/sapl/parlamentares/models.py b/sapl/parlamentares/models.py index 86e174f09..9d43e6d6a 100644 --- a/sapl/parlamentares/models.py +++ b/sapl/parlamentares/models.py @@ -5,6 +5,7 @@ from django.utils import timezone from django.utils.translation import ugettext_lazy as _ from image_cropping.fields import ImageCropField, ImageRatioField from model_utils import Choices + from sapl.base.models import Autor from sapl.decorators import vigencia_atual from sapl.utils import (INDICADOR_AFASTAMENTO, LISTA_DE_UFS, YES_NO_CHOICES, diff --git a/sapl/parlamentares/tests/test_mandato.py b/sapl/parlamentares/tests/test_mandato.py index df0aabc7f..cc027da1f 100644 --- a/sapl/parlamentares/tests/test_mandato.py +++ b/sapl/parlamentares/tests/test_mandato.py @@ -2,6 +2,7 @@ from datetime import datetime import pytest from model_mommy import mommy + from sapl.parlamentares.models import Filiacao, Legislatura, Mandato pytestmark = pytest.mark.django_db diff --git a/sapl/parlamentares/tests/test_parlamentares.py b/sapl/parlamentares/tests/test_parlamentares.py index 4605f7af6..3bd7abf47 100644 --- a/sapl/parlamentares/tests/test_parlamentares.py +++ b/sapl/parlamentares/tests/test_parlamentares.py @@ -2,6 +2,7 @@ import pytest from django.core.urlresolvers import reverse from django.utils.translation import ugettext_lazy as _ from model_mommy import mommy + from sapl.parlamentares.forms import FrenteForm, LegislaturaForm, MandatoForm from sapl.parlamentares.models import (Dependente, Filiacao, Legislatura, Mandato, Parlamentar, Partido, diff --git a/sapl/parlamentares/urls.py b/sapl/parlamentares/urls.py index 4f7cd4c91..e383421c4 100644 --- a/sapl/parlamentares/urls.py +++ b/sapl/parlamentares/urls.py @@ -1,4 +1,5 @@ from django.conf.urls import include, url + from sapl.parlamentares.views import (CargoMesaCrud, ColigacaoCrud, ComposicaoColigacaoCrud, DependenteCrud, FiliacaoCrud, FrenteCrud, FrenteList, diff --git a/sapl/parlamentares/views.py b/sapl/parlamentares/views.py index 7654dde6c..8baaadda2 100644 --- a/sapl/parlamentares/views.py +++ b/sapl/parlamentares/views.py @@ -1,5 +1,5 @@ -from datetime import datetime import json +from datetime import datetime from django.contrib import messages from django.contrib.contenttypes.models import ContentType @@ -33,7 +33,6 @@ from .models import (CargoMesa, Coligacao, ComposicaoColigacao, ComposicaoMesa, NivelInstrucao, Parlamentar, Partido, SessaoLegislativa, SituacaoMilitar, TipoAfastamento, TipoDependente, Votante) - CargoMesaCrud = CrudAux.build(CargoMesa, 'cargo_mesa') PartidoCrud = CrudAux.build(Partido, 'partidos') SessaoLegislativaCrud = CrudAux.build(SessaoLegislativa, 'sessao_legislativa') diff --git a/sapl/protocoloadm/forms.py b/sapl/protocoloadm/forms.py index 4f68478ce..de647a243 100644 --- a/sapl/protocoloadm/forms.py +++ b/sapl/protocoloadm/forms.py @@ -10,12 +10,13 @@ from django.db import models from django.forms import ModelForm from django.utils import timezone from django.utils.translation import ugettext_lazy as _ + from sapl.base.models import Autor, TipoAutor from sapl.crispy_layout_mixin import SaplFormLayout, form_actions, to_row from sapl.materia.models import (MateriaLegislativa, TipoMateriaLegislativa, UnidadeTramitacao) -from sapl.utils import (RANGE_ANOS, AnoNumeroOrderingFilter, - RangeWidgetOverride, autor_label, autor_modal, YES_NO_CHOICES) +from sapl.utils import (RANGE_ANOS, YES_NO_CHOICES, AnoNumeroOrderingFilter, + RangeWidgetOverride, autor_label, autor_modal) from .models import (DocumentoAcessorioAdministrativo, DocumentoAdministrativo, Protocolo, TipoDocumentoAdministrativo, @@ -363,7 +364,6 @@ class ProtocoloMateriaForm(ModelForm): empty_label='Selecione', ) - numero_materia = forms.CharField( label=_('Número matéria'), required=False) @@ -372,7 +372,7 @@ class ProtocoloMateriaForm(ModelForm): vincular_materia = forms.ChoiceField(label=_('Vincular a matéria existente?'), widget=forms.RadioSelect(), - choices= YES_NO_CHOICES, + choices=YES_NO_CHOICES, initial=False) numero_paginas = forms.CharField(label=_('Núm. Páginas'), required=True) @@ -414,7 +414,8 @@ class ProtocoloMateriaForm(ModelForm): if data['vincular_materia'] == 'True': try: if not data['ano_materia'] or not data['numero_materia']: - raise ValidationError('Favor informar o número e ano da matéria a ser vinculada') + raise ValidationError( + 'Favor informar o número e ano da matéria a ser vinculada') self.materia = MateriaLegislativa.objects.get(ano=data['ano_materia'], numero=data['numero_materia'], tipo=data['tipo_materia']) @@ -426,8 +427,6 @@ class ProtocoloMateriaForm(ModelForm): return data - - def __init__(self, *args, **kwargs): row1 = to_row( @@ -438,7 +437,7 @@ class ProtocoloMateriaForm(ModelForm): row2 = to_row( [('vincular_materia', 4), ('numero_materia', 4), - ('ano_materia', 4),]) + ('ano_materia', 4), ]) row3 = to_row( [('assunto_ementa', 12)]) row4 = to_row( diff --git a/sapl/protocoloadm/models.py b/sapl/protocoloadm/models.py index 43e18ffd5..d4d45b3ad 100644 --- a/sapl/protocoloadm/models.py +++ b/sapl/protocoloadm/models.py @@ -2,6 +2,7 @@ import reversion from django.db import models from django.utils.translation import ugettext_lazy as _ from model_utils import Choices + from sapl.base.models import Autor from sapl.materia.models import TipoMateriaLegislativa, UnidadeTramitacao from sapl.utils import RANGE_ANOS, YES_NO_CHOICES, texto_upload_path diff --git a/sapl/protocoloadm/tests/test_protocoloadm.py b/sapl/protocoloadm/tests/test_protocoloadm.py index 216a0f24d..f74c4dd7b 100644 --- a/sapl/protocoloadm/tests/test_protocoloadm.py +++ b/sapl/protocoloadm/tests/test_protocoloadm.py @@ -5,6 +5,7 @@ from django.core.urlresolvers import reverse from django.utils.encoding import force_text from django.utils.translation import ugettext_lazy as _ from model_mommy import mommy + from sapl.materia.models import UnidadeTramitacao from sapl.protocoloadm.forms import (AnularProcoloAdmForm, DocumentoAdministrativoForm, diff --git a/sapl/protocoloadm/urls.py b/sapl/protocoloadm/urls.py index 77512ff01..46fec9980 100644 --- a/sapl/protocoloadm/urls.py +++ b/sapl/protocoloadm/urls.py @@ -1,4 +1,5 @@ from django.conf.urls import include, url + from sapl.protocoloadm.views import (AnularProtocoloAdmView, ComprovanteProtocoloView, CriarDocumentoProtocolo, diff --git a/sapl/protocoloadm/views.py b/sapl/protocoloadm/views.py index 14ba66d0f..b92975744 100644 --- a/sapl/protocoloadm/views.py +++ b/sapl/protocoloadm/views.py @@ -1,5 +1,4 @@ -import sapl from braces.views import FormValidMessageMixin from django.contrib import messages from django.contrib.auth.mixins import PermissionRequiredMixin @@ -15,6 +14,8 @@ from django.utils.translation import ugettext_lazy as _ from django.views.generic import CreateView, ListView from django.views.generic.base import RedirectView, TemplateView from django_filters.views import FilterView + +import sapl from sapl.base.models import Autor from sapl.comissoes.models import Comissao from sapl.crud.base import Crud, CrudAux, MasterDetailCrud, make_pagination diff --git a/sapl/redireciona_urls/views.py b/sapl/redireciona_urls/views.py index 4f1480a13..64e03e36c 100644 --- a/sapl/redireciona_urls/views.py +++ b/sapl/redireciona_urls/views.py @@ -1,5 +1,6 @@ from django.core.urlresolvers import NoReverseMatch, reverse from django.views.generic import RedirectView + from sapl.base.apps import AppConfig as atasConfig from sapl.comissoes.apps import AppConfig as comissoesConfig from sapl.materia.apps import AppConfig as materiaConfig @@ -635,6 +636,7 @@ class RedirecionaMateriasPorAnoAutorTipo(RedirectView): return url + class RedirecionaReuniao(RedirectView): permanent = True diff --git a/sapl/relatorios/views.py b/sapl/relatorios/views.py index eace383dd..00f33e44e 100644 --- a/sapl/relatorios/views.py +++ b/sapl/relatorios/views.py @@ -6,6 +6,7 @@ from django.core.exceptions import ObjectDoesNotExist from django.http import Http404, HttpResponse from django.utils import timezone from django.utils.translation import ugettext_lazy as _ + from sapl.base.models import Autor, CasaLegislativa from sapl.comissoes.models import Comissao from sapl.materia.models import (Autoria, MateriaLegislativa, Numeracao, @@ -947,8 +948,8 @@ def get_etiqueta_protocolos(prots): dic['num_materia'] = '' for materia in MateriaLegislativa.objects.filter( numero_protocolo=p.numero, ano=p.ano): - dic['num_materia'] = materia.tipo.sigla + ' ' + str(materia.numero) + '/' + str(materia.ano) - + dic['num_materia'] = materia.tipo.sigla + ' ' + \ + str(materia.numero) + '/' + str(materia.ano) dic['natureza'] = '' if p.tipo_processo == 0: @@ -959,8 +960,6 @@ def get_etiqueta_protocolos(prots): else: dic['natureza'] = 'Legislativo' - - dic['num_documento'] = '' for documento in DocumentoAdministrativo.objects.filter( protocolo=p): diff --git a/sapl/rules/apps.py b/sapl/rules/apps.py index 2b03bf239..606190110 100644 --- a/sapl/rules/apps.py +++ b/sapl/rules/apps.py @@ -10,6 +10,7 @@ from django.db import models, router from django.db.utils import DEFAULT_DB_ALIAS from django.utils.translation import ugettext_lazy as _ from django.utils.translation import string_concat + from sapl.rules import (SAPL_GROUP_ADMINISTRATIVO, SAPL_GROUP_COMISSOES, SAPL_GROUP_GERAL, SAPL_GROUP_MATERIA, SAPL_GROUP_NORMA, SAPL_GROUP_PAINEL, SAPL_GROUP_PROTOCOLO, diff --git a/sapl/rules/tests/test_rules.py b/sapl/rules/tests/test_rules.py index 8657290b8..aa97cb5e5 100644 --- a/sapl/rules/tests/test_rules.py +++ b/sapl/rules/tests/test_rules.py @@ -5,6 +5,7 @@ from django.contrib.auth.models import Permission from django.contrib.contenttypes.models import ContentType from django.utils import six from django.utils.translation import ugettext_lazy as _ + from sapl.base.models import (Argumento, CasaLegislativa, Constraint, ProblemaMigracao) from sapl.compilacao.models import (PerfilEstruturalTextoArticulado, diff --git a/sapl/sessao/forms.py b/sapl/sessao/forms.py index 59fd3391c..40b09c762 100644 --- a/sapl/sessao/forms.py +++ b/sapl/sessao/forms.py @@ -9,6 +9,7 @@ from django.core.exceptions import ObjectDoesNotExist, ValidationError from django.db import transaction from django.forms import ModelForm from django.utils.translation import ugettext_lazy as _ + from sapl.base.models import Autor, TipoAutor from sapl.crispy_layout_mixin import form_actions, to_row from sapl.materia.forms import MateriaLegislativaFilterSet diff --git a/sapl/sessao/tests/test_sessao_view.py b/sapl/sessao/tests/test_sessao_view.py index 29e27c169..082652c19 100644 --- a/sapl/sessao/tests/test_sessao_view.py +++ b/sapl/sessao/tests/test_sessao_view.py @@ -2,6 +2,7 @@ import pytest from django.core.urlresolvers import reverse from django.utils.translation import ugettext_lazy as _ from model_mommy import mommy + from sapl.parlamentares.models import Legislatura, SessaoLegislativa from sapl.sessao.models import SessaoPlenaria, TipoSessaoPlenaria diff --git a/sapl/sessao/urls.py b/sapl/sessao/urls.py index 729c43d58..18b1608df 100644 --- a/sapl/sessao/urls.py +++ b/sapl/sessao/urls.py @@ -1,4 +1,5 @@ from django.conf.urls import include, url + from sapl.sessao.views import (AdicionarVariasMateriasExpediente, AdicionarVariasMateriasOrdemDia, BancadaCrud, BlocoCrud, CargoBancadaCrud, diff --git a/sapl/sessao/views.py b/sapl/sessao/views.py index ab0f2fec4..57fa69c09 100644 --- a/sapl/sessao/views.py +++ b/sapl/sessao/views.py @@ -20,6 +20,7 @@ from django.views.generic.base import RedirectView from django.views.generic.detail import DetailView from django.views.generic.edit import FormMixin from django_filters.views import FilterView + from sapl.base.models import AppConfig as AppsAppConfig from sapl.crud.base import (RP_DETAIL, RP_LIST, Crud, CrudAux, MasterDetailCrud, @@ -592,7 +593,7 @@ class BlocoCrud(Crud): class ListView(Crud.ListView): template_name = 'crud/list_tabaux.html' - + class CreateView(Crud.CreateView): form_class = BlocoForm diff --git a/sapl/test_crispy_layout_mixin.py b/sapl/test_crispy_layout_mixin.py index bb063a445..2c72a1b44 100644 --- a/sapl/test_crispy_layout_mixin.py +++ b/sapl/test_crispy_layout_mixin.py @@ -1,6 +1,7 @@ from unittest import mock import rtyaml + from sapl.crispy_layout_mixin import read_layout_from_yaml diff --git a/sapl/test_urls.py b/sapl/test_urls.py index 9c462fc19..ebc88da2b 100644 --- a/sapl/test_urls.py +++ b/sapl/test_urls.py @@ -1,12 +1,12 @@ +import pytest from django.apps import apps from django.contrib.auth import get_user_model from django.contrib.auth.management import _get_all_permissions from django.contrib.auth.models import Permission from django.contrib.contenttypes.models import ContentType from django.db import transaction -from django.utils.translation import string_concat from django.utils.translation import ugettext_lazy as _ -import pytest +from django.utils.translation import string_concat from sapl.crud.base import PermissionRequiredForAppCrudMixin from sapl.rules.apps import AppConfig, update_groups @@ -14,7 +14,6 @@ from scripts.lista_urls import lista_urls from .settings import SAPL_APPS - pytestmark = pytest.mark.django_db sapl_appconfs = [apps.get_app_config(n[5:]) for n in SAPL_APPS] diff --git a/sapl/urls.py b/sapl/urls.py index d5d6cc652..38667b4e7 100644 --- a/sapl/urls.py +++ b/sapl/urls.py @@ -13,6 +13,13 @@ Including another URLconf 1. Add an import: from blog import urls as blog_urls 2. Add a URL to urlpatterns: url(r'^blog/', include(blog_urls)) """ +from django.conf import settings +from django.conf.urls import include, url +from django.conf.urls.static import static +from django.contrib import admin +from django.views.generic.base import RedirectView, TemplateView +from django.views.static import serve as view_static_server + import sapl.api.urls import sapl.base.urls import sapl.comissoes.urls @@ -26,12 +33,6 @@ import sapl.protocoloadm.urls import sapl.redireciona_urls.urls import sapl.relatorios.urls import sapl.sessao.urls -from django.conf import settings -from django.conf.urls import include, url -from django.conf.urls.static import static -from django.contrib import admin -from django.views.generic.base import RedirectView, TemplateView -from django.views.static import serve as view_static_server urlpatterns = [ url(r'^$', TemplateView.as_view(template_name='index.html'), diff --git a/sapl/utils.py b/sapl/utils.py index 80f1d3414..1e92bf7cd 100644 --- a/sapl/utils.py +++ b/sapl/utils.py @@ -1,11 +1,13 @@ -from functools import wraps -from operator import itemgetter -from unicodedata import normalize as unicodedata_normalize import hashlib import logging import os import re +from functools import wraps +from operator import itemgetter +from unicodedata import normalize as unicodedata_normalize +import django_filters +import magic from crispy_forms.helper import FormHelper from crispy_forms.layout import HTML, Button from django import forms @@ -23,13 +25,10 @@ from easy_thumbnails import source_generators from floppyforms import ClearableFileInput from reversion.admin import VersionAdmin from unipath.path import Path -import django_filters -import magic from sapl.crispy_layout_mixin import SaplFormLayout, form_actions, to_row from sapl.settings import BASE_DIR - sapl_logger = logging.getLogger(BASE_DIR.name) @@ -49,7 +48,7 @@ def clear_thumbnails_cache(queryset, field): path = Path(getattr(r, field).path) if not path.exists(): - continue + continue cache_files = path.parent.walk() diff --git a/scripts/anonimizador/anon.py b/scripts/anonimizador/anon.py index 13aef6ad7..98618cee7 100644 --- a/scripts/anonimizador/anon.py +++ b/scripts/anonimizador/anon.py @@ -5,6 +5,7 @@ from string import digits from django.apps import apps from django.db.models.fields import CharField, TextField + from sapl.materia.models import Orgao, Origem from sapl.norma.models import AssuntoNorma from sapl.parlamentares.models import Municipio, NivelInstrucao, Partido diff --git a/scripts/convert_null_to_empty_in_all_char_fields.py b/scripts/convert_null_to_empty_in_all_char_fields.py index 2a8699217..8ad5243a7 100644 --- a/scripts/convert_null_to_empty_in_all_char_fields.py +++ b/scripts/convert_null_to_empty_in_all_char_fields.py @@ -1,5 +1,6 @@ from django.apps import apps from django.db import models + from sapl.settings import SAPL_APPS diff --git a/scripts/fk_protocoloadm_docadm.py b/scripts/fk_protocoloadm_docadm.py index cb66a74bd..a4294206c 100644 --- a/scripts/fk_protocoloadm_docadm.py +++ b/scripts/fk_protocoloadm_docadm.py @@ -3,6 +3,7 @@ from django.core.exceptions import ObjectDoesNotExist + from sapl.protocoloadm.models import DocumentoAdministrativo, Protocolo