From 698e53a8c55bdb16752ed60099f739d3d2e8863d Mon Sep 17 00:00:00 2001 From: Edward Ribeiro Date: Tue, 1 Nov 2016 09:10:56 -0200 Subject: [PATCH] Ajusta QA check --- sapl/base/templatetags/common_tags.py | 1 + sapl/materia/forms.py | 6 +++--- sapl/materia/tests/test_materia.py | 2 +- sapl/materia/views.py | 4 +--- sapl/painel/views.py | 1 - sapl/protocoloadm/forms.py | 3 +-- sapl/protocoloadm/urls.py | 2 +- sapl/protocoloadm/views.py | 9 ++++----- sapl/rules/tests/test_rules.py | 3 +-- sapl/sessao/views.py | 2 -- sapl/utils.py | 18 +++++++----------- 11 files changed, 20 insertions(+), 31 deletions(-) diff --git a/sapl/base/templatetags/common_tags.py b/sapl/base/templatetags/common_tags.py index d023104d5..b4f4bb23d 100644 --- a/sapl/base/templatetags/common_tags.py +++ b/sapl/base/templatetags/common_tags.py @@ -3,6 +3,7 @@ from django import template from sapl.base.models import AppConfig from sapl.parlamentares.models import Filiacao + register = template.Library() diff --git a/sapl/materia/forms.py b/sapl/materia/forms.py index 8ba0e5477..b9a3db1ed 100644 --- a/sapl/materia/forms.py +++ b/sapl/materia/forms.py @@ -1,7 +1,8 @@ -from datetime import date, datetime import os +from datetime import date, datetime +import django_filters from crispy_forms.bootstrap import (Alert, FormActions, InlineCheckboxes, InlineRadios) from crispy_forms.helper import FormHelper @@ -17,8 +18,8 @@ from django.db.models import Max from django.forms import ModelForm, widgets from django.forms.forms import Form from django.utils.translation import ugettext_lazy as _ -import django_filters +import sapl from sapl.base.models import Autor from sapl.comissoes.models import Comissao from sapl.crispy_layout_mixin import (SaplFormLayout, form_actions, to_column, @@ -32,7 +33,6 @@ from sapl.settings import MAX_DOC_UPLOAD_SIZE from sapl.utils import (RANGE_ANOS, YES_NO_CHOICES, ChoiceWithoutValidationField, RangeWidgetOverride, autor_label, autor_modal, models_with_gr_for_model) -import sapl from .models import (AcompanhamentoMateria, Anexada, Autoria, DespachoInicial, DocumentoAcessorio, MateriaLegislativa, Numeracao, diff --git a/sapl/materia/tests/test_materia.py b/sapl/materia/tests/test_materia.py index 5455792f4..a8aaaf2ec 100644 --- a/sapl/materia/tests/test_materia.py +++ b/sapl/materia/tests/test_materia.py @@ -1,9 +1,9 @@ +import pytest 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 model_mommy import mommy -import pytest from sapl.base.models import Autor, TipoAutor from sapl.comissoes.models import Comissao, TipoComissao diff --git a/sapl/materia/views.py b/sapl/materia/views.py index 30d038f23..e1a686f1f 100644 --- a/sapl/materia/views.py +++ b/sapl/materia/views.py @@ -21,6 +21,7 @@ from django.views.generic.base import RedirectView from django.views.generic.edit import FormView from django_filters.views import FilterView +import sapl from sapl.base.models import Autor, CasaLegislativa from sapl.compilacao.views import IntegracaoTaView from sapl.crispy_layout_mixin import SaplFormLayout, form_actions @@ -28,7 +29,6 @@ from sapl.crud.base import (ACTION_CREATE, ACTION_DELETE, ACTION_DETAIL, ACTION_LIST, ACTION_UPDATE, RP_DETAIL, RP_LIST, Crud, CrudAux, MasterDetailCrud, PermissionRequiredForAppCrudMixin, make_pagination) -from sapl.materia import apps from sapl.materia.forms import (AnexadaForm, ConfirmarProposicaoForm, LegislacaoCitadaForm, ProposicaoForm, TipoProposicaoForm) @@ -36,7 +36,6 @@ from sapl.norma.models import LegislacaoCitada from sapl.utils import (TURNO_TRAMITACAO_CHOICES, YES_NO_CHOICES, autor_label, autor_modal, gerar_hash_arquivo, get_base_url, montar_row_autor) -import sapl from .forms import (AcessorioEmLoteFilterSet, AcompanhamentoMateriaForm, DocumentoAcessorioForm, MateriaLegislativaFilterSet, @@ -51,7 +50,6 @@ from .models import (AcompanhamentoMateria, Anexada, Autoria, DespachoInicial, TipoMateriaLegislativa, TipoProposicao, Tramitacao, UnidadeTramitacao) - OrigemCrud = Crud.build(Origem, '') TipoMateriaCrud = CrudAux.build( diff --git a/sapl/painel/views.py b/sapl/painel/views.py index d43555f51..6c43708a4 100644 --- a/sapl/painel/views.py +++ b/sapl/painel/views.py @@ -16,7 +16,6 @@ from sapl.sessao.models import (ExpedienteMateria, OrdemDia, PresencaOrdemDia, from .models import Cronometro - CronometroPainelCrud = Crud.build(Cronometro, '') # FIXME mudar lógica diff --git a/sapl/protocoloadm/forms.py b/sapl/protocoloadm/forms.py index de17af830..0315d6f1c 100644 --- a/sapl/protocoloadm/forms.py +++ b/sapl/protocoloadm/forms.py @@ -1,5 +1,6 @@ from datetime import datetime +import django_filters from crispy_forms.bootstrap import InlineRadios from crispy_forms.helper import FormHelper from crispy_forms.layout import HTML, Button, Fieldset, Layout, Submit @@ -8,7 +9,6 @@ from django.core.exceptions import ObjectDoesNotExist, ValidationError from django.db import models from django.forms import ModelForm from django.utils.translation import ugettext_lazy as _ -import django_filters from sapl.base.models import Autor from sapl.crispy_layout_mixin import form_actions, to_row @@ -20,7 +20,6 @@ from .models import (DocumentoAcessorioAdministrativo, DocumentoAdministrativo, Protocolo, TipoDocumentoAdministrativo, TramitacaoAdministrativo) - TIPOS_PROTOCOLO = [('0', 'Enviado'), ('1', 'Recebido'), ('', 'Ambos')] NATUREZA_PROCESSO = [('', 'Ambos'), diff --git a/sapl/protocoloadm/urls.py b/sapl/protocoloadm/urls.py index 07c89029e..1de09a01a 100644 --- a/sapl/protocoloadm/urls.py +++ b/sapl/protocoloadm/urls.py @@ -9,7 +9,7 @@ from sapl.protocoloadm.views import (AnularProtocoloAdmView, DocumentoAcessorioAdministrativoView, DocumentoAdministrativoCrud, PesquisarDocumentoAdministrativoView, - ProtocoloDocumentoView, ProtocoloListView, + ProtocoloDocumentoView, ProtocoloMateriaView, ProtocoloMostrarView, ProtocoloPesquisaView, diff --git a/sapl/protocoloadm/views.py b/sapl/protocoloadm/views.py index 0e78cce97..5019d47bf 100644 --- a/sapl/protocoloadm/views.py +++ b/sapl/protocoloadm/views.py @@ -12,10 +12,10 @@ from django.views.generic import CreateView, DetailView, FormView, ListView from django.views.generic.base import TemplateView from django_filters.views import FilterView +import sapl from sapl.crud.base import Crud, CrudAux, MasterDetailCrud, make_pagination from sapl.materia.models import TipoMateriaLegislativa -from sapl.utils import (create_barcode, get_client_ip) -import sapl +from sapl.utils import create_barcode, get_client_ip from .forms import (AnularProcoloAdmForm, DocumentoAcessorioAdministrativoForm, DocumentoAdministrativoFilterSet, @@ -26,14 +26,13 @@ from .models import (DocumentoAcessorioAdministrativo, DocumentoAdministrativo, Protocolo, StatusTramitacaoAdministrativo, TipoDocumentoAdministrativo, TramitacaoAdministrativo) - TipoDocumentoAdministrativoCrud = CrudAux.build( TipoDocumentoAdministrativo, '') -#ProtocoloDocumentoCrud = Crud.build(Protocolo, '') +# ProtocoloDocumentoCrud = Crud.build(Protocolo, '') # FIXME precisa de uma chave diferente para o layout -#ProtocoloMateriaCrud = Crud.build(Protocolo, '') +# ProtocoloMateriaCrud = Crud.build(Protocolo, '') DocumentoAcessorioAdministrativoCrud = Crud.build( diff --git a/sapl/rules/tests/test_rules.py b/sapl/rules/tests/test_rules.py index bdc885558..0dcd808b0 100644 --- a/sapl/rules/tests/test_rules.py +++ b/sapl/rules/tests/test_rules.py @@ -1,10 +1,10 @@ +import pytest from django.apps import apps from django.conf import settings 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 _ -import pytest from sapl.base.models import CasaLegislativa, ProblemaMigracao from sapl.compilacao.models import TipoDispositivo,\ @@ -17,7 +17,6 @@ from scripts.lista_permissions_in_decorators import \ lista_permissions_in_decorators from scripts.lista_urls import lista_urls - sapl_appconfs = [apps.get_app_config(n[5:]) for n in settings.SAPL_APPS] sapl_models = [] diff --git a/sapl/sessao/views.py b/sapl/sessao/views.py index f36381233..3fc239e02 100644 --- a/sapl/sessao/views.py +++ b/sapl/sessao/views.py @@ -29,7 +29,6 @@ from sapl.materia.views import MateriaLegislativaPesquisaView from sapl.norma.models import NormaJuridica from sapl.parlamentares.models import (Legislatura, Parlamentar, SessaoLegislativa) - from sapl.sessao.apps import AppConfig from sapl.sessao.forms import ExpedienteMateriaForm, OrdemDiaForm @@ -45,7 +44,6 @@ from .models import (Bancada, Bloco, CargoBancada, CargoMesa, SessaoPlenariaPresenca, TipoExpediente, TipoResultadoVotacao, TipoSessaoPlenaria, VotoParlamentar) - TipoSessaoCrud = CrudAux.build(TipoSessaoPlenaria, 'tipo_sessao_plenaria') TipoExpedienteCrud = CrudAux.build(TipoExpediente, 'tipo_expediente') CargoBancadaCrud = CrudAux.build(CargoBancada, '') diff --git a/sapl/utils.py b/sapl/utils.py index 792099eaf..3969cfb74 100644 --- a/sapl/utils.py +++ b/sapl/utils.py @@ -1,30 +1,26 @@ -from datetime import date -from functools import wraps -from unicodedata import normalize as unicodedata_normalize import hashlib import logging import re +from datetime import date +from functools import wraps +from unicodedata import normalize as unicodedata_normalize +import magic from crispy_forms.helper import FormHelper from crispy_forms.layout import HTML, Button from django import forms from django.apps import apps from django.conf import settings from django.contrib import admin -from django.contrib.auth.decorators import user_passes_test -from django.contrib.auth.models import Permission from django.contrib.contenttypes.fields import (GenericForeignKey, GenericRel, GenericRelation) -from django.contrib.contenttypes.models import ContentType -from django.core.exceptions import PermissionDenied, ValidationError +from django.core.exceptions import ValidationError from django.utils.translation import ugettext_lazy as _ from floppyforms import ClearableFileInput -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) @@ -399,12 +395,12 @@ def permissoes(nome_grupo, app_label): def permission_required_for_app(app_label, login_url=None, raise_exception=False): - + Decorator for views that checks whether a user has a particular permission enabled, redirecting to the log-in page if necessary. If the raise_exception parameter is given the PermissionDenied exception is raised. - + def check_perms(user): if user.has_module_perms(app_label): return True