diff --git a/sapl/base/views.py b/sapl/base/views.py index f1474ae4a..47c3a5318 100644 --- a/sapl/base/views.py +++ b/sapl/base/views.py @@ -1,6 +1,5 @@ from django.conf import settings from django.contrib.auth import get_user_model -from django.contrib.auth.mixins import PermissionRequiredMixin from django.contrib.auth.models import Group from django.contrib.auth.tokens import default_token_generator from django.core.exceptions import ObjectDoesNotExist diff --git a/sapl/materia/email_utils.py b/sapl/materia/email_utils.py index 9bfe0b66f..3dc6b220d 100644 --- a/sapl/materia/email_utils.py +++ b/sapl/materia/email_utils.py @@ -152,8 +152,8 @@ def criar_email_tramitacao(base_url, casa_legislativa, materia, status, 'email/tramitacao.html'], {"casa_legislativa": casa_nome, "data_registro": dt.strftime( - timezone.now(), - "%d/%m/%Y"), + timezone.now(), + "%d/%m/%Y"), "cod_materia": materia.id, "logotipo": casa_legislativa.logotipo, "descricao_materia": materia.ementa, diff --git a/sapl/materia/views.py b/sapl/materia/views.py index 9c315be5a..1fa65bd85 100644 --- a/sapl/materia/views.py +++ b/sapl/materia/views.py @@ -1642,7 +1642,7 @@ class DocumentoAcessorioEmLoteView(PermissionRequiredMixin, FilterView): doc.arquivo = request.FILES['arquivo'] doc.nome = request.POST['nome'] doc.data = tz.localize(datetime.strptime( - request.POST['data'], "%d/%m/%Y")) + request.POST['data'], "%d/%m/%Y")) doc.autor = request.POST['autor'] doc.ementa = request.POST['ementa'] doc.save() diff --git a/sapl/painel/urls.py b/sapl/painel/urls.py index 2dc5dcdb9..0795d0a35 100644 --- a/sapl/painel/urls.py +++ b/sapl/painel/urls.py @@ -25,4 +25,3 @@ urlpatterns = [ url(r'^voto-individual/$', votante_view, name='voto_individual'), ] - diff --git a/sapl/painel/views.py b/sapl/painel/views.py index cc01cbf34..eae434de3 100644 --- a/sapl/painel/views.py +++ b/sapl/painel/views.py @@ -1,4 +1,5 @@ import json + from django.contrib import messages from django.contrib.auth.decorators import user_passes_test from django.core.exceptions import ObjectDoesNotExist @@ -8,8 +9,6 @@ from django.http import HttpResponse, JsonResponse from django.http.response import Http404, HttpResponseRedirect from django.shortcuts import render from django.utils.translation import ugettext_lazy as _ -from operator import itemgetter -from sapl.utils import sort_lista_chave from sapl.crud.base import Crud from sapl.painel.apps import AppConfig @@ -17,7 +16,7 @@ from sapl.parlamentares.models import Votante from sapl.sessao.models import (ExpedienteMateria, OrdemDia, PresencaOrdemDia, RegistroVotacao, SessaoPlenaria, SessaoPlenariaPresenca, VotoParlamentar) -from sapl.utils import filiacao_data, get_client_ip +from sapl.utils import filiacao_data, get_client_ip, sort_lista_chave from .models import Cronometro @@ -238,6 +237,7 @@ def switch_painel(request): sessao.save() return JsonResponse({}) + @user_passes_test(check_permission) def verifica_painel(request): sessao = SessaoPlenaria.objects.get(id=request.GET['pk_sessao']) @@ -324,7 +324,6 @@ def get_presentes(pk, response, materia): 'materia_legislativa_texto': str(materia.materia) }) - presentes_list = sort_lista_chave(presentes_list, 'nome') response.update({ diff --git a/sapl/parlamentares/tests/test_parlamentares.py b/sapl/parlamentares/tests/test_parlamentares.py index 88644750f..ba1f560b9 100644 --- a/sapl/parlamentares/tests/test_parlamentares.py +++ b/sapl/parlamentares/tests/test_parlamentares.py @@ -128,7 +128,8 @@ def test_mandato_submit(admin_client): kwargs={'pk': 14}), {'parlamentar': 14, # hidden field 'legislatura': 5, - 'data_inicio_mandato': Legislatura.objects.get(id=5).data_inicio, + 'data_inicio_mandato': \ + Legislatura.objects.get(id=5).data_inicio, 'data_expedicao_diploma': '2016-03-22', 'observacao': 'Observação do mandato', 'salvar': 'salvar'}, diff --git a/sapl/protocoloadm/forms.py b/sapl/protocoloadm/forms.py index e3874181f..d7d720315 100644 --- a/sapl/protocoloadm/forms.py +++ b/sapl/protocoloadm/forms.py @@ -598,7 +598,7 @@ class DocumentoAdministrativoForm(ModelForm): except MultipleObjectsReturned: msg = _( 'Existe mais de um Protocolo com este ano e número.' % ( - numero_protocolo, ano_protocolo)) + numero_protocolo, ano_protocolo)) raise ValidationError(msg) return self.cleaned_data diff --git a/sapl/sessao/forms.py b/sapl/sessao/forms.py index f767cb5d4..6fddc6747 100644 --- a/sapl/sessao/forms.py +++ b/sapl/sessao/forms.py @@ -129,7 +129,7 @@ class ExpedienteMateriaForm(ModelForm): label='Número Matéria', required=True) ano_materia = forms.CharField( - label='Ano Matéria', + label='Ano Matéria', initial=int(data_atual.year), required=True) diff --git a/sapl/sessao/models.py b/sapl/sessao/models.py index b5d31fff7..7d87ecef2 100644 --- a/sapl/sessao/models.py +++ b/sapl/sessao/models.py @@ -111,7 +111,8 @@ class SessaoPlenaria(models.Model): # TODO analyze querying all hosted databases ! cod_andamento_sessao = models.PositiveIntegerField(blank=True, null=True) - painel_aberto = models.BooleanField(blank=True, default=False, verbose_name=_('Painel está aberto?')) + painel_aberto = models.BooleanField(blank=True, default=False, + verbose_name=_('Painel está aberto?')) tipo = models.ForeignKey(TipoSessaoPlenaria, on_delete=models.PROTECT, verbose_name=_('Tipo')) diff --git a/sapl/sessao/tests/test_sessao.py b/sapl/sessao/tests/test_sessao.py index b0258312c..038ad7424 100644 --- a/sapl/sessao/tests/test_sessao.py +++ b/sapl/sessao/tests/test_sessao.py @@ -2,7 +2,7 @@ import pytest from django.utils.translation import ugettext_lazy as _ from model_mommy import mommy -from sapl.materia.models import TipoMateriaLegislativa, MateriaLegislativa +from sapl.materia.models import MateriaLegislativa, TipoMateriaLegislativa from sapl.parlamentares.models import Legislatura, Partido, SessaoLegislativa from sapl.sessao import forms from sapl.sessao.models import (ExpedienteMateria, SessaoPlenaria, diff --git a/sapl/sessao/tests/test_sessao_view.py b/sapl/sessao/tests/test_sessao_view.py index 8868d7abd..082652c19 100644 --- a/sapl/sessao/tests/test_sessao_view.py +++ b/sapl/sessao/tests/test_sessao_view.py @@ -46,4 +46,4 @@ def test_incluir_sessao_errors(admin_client): assert (response.context_data['form'].errors['data_inicio'] == [_('Este campo é obrigatório.')]) assert (response.context_data['form'].errors['hora_inicio'] == - [_('Este campo é obrigatório.')]) \ No newline at end of file + [_('Este campo é obrigatório.')]) diff --git a/sapl/utils.py b/sapl/utils.py index 37e5711d3..d645cb003 100644 --- a/sapl/utils.py +++ b/sapl/utils.py @@ -3,8 +3,8 @@ import logging import os import re from functools import wraps -from unicodedata import normalize as unicodedata_normalize from operator import itemgetter +from unicodedata import normalize as unicodedata_normalize import django_filters import magic @@ -657,7 +657,8 @@ def show_results_filter_set(qr): def sort_lista_chave(lista, chave): """ :param lista: Uma list a ser ordenada . - :param chave: Algum atributo (chave) que está presente na lista e qual deve ser usado para a ordenação da nova + :param chave: Algum atributo (chave) que está presente na lista e qual + deve ser usado para a ordenação da nova lista. :return: A lista ordenada pela chave passada. """ diff --git a/scripts/lista_permissions_in_decorators.py b/scripts/lista_permissions_in_decorators.py index 4d504e6c0..d20882450 100644 --- a/scripts/lista_permissions_in_decorators.py +++ b/scripts/lista_permissions_in_decorators.py @@ -17,7 +17,7 @@ def get_decorators(cls): target = cls decorators = {} - def visit_FunctionDef(node): + def visit_functionDef(node): decorators[node.name] = [] for n in node.decorator_list: name = '' @@ -30,7 +30,7 @@ def get_decorators(cls): decorators[node.name].append(name) node_iter = ast.NodeVisitor() - node_iter.visit_FunctionDef = visit_FunctionDef + node_iter.visit_functionDef = visit_functionDef node_iter.visit(ast.parse(inspect.getsource(target))) return decorators @@ -77,7 +77,7 @@ def get_permission_requireds(cls): get_permission_required(arg) - def visit_FunctionDef(node): + def visit_functionDef(node): for n in node.decorator_list: if not isinstance(n, ast.Call): continue @@ -98,7 +98,7 @@ def get_permission_requireds(cls): get_method_decorator(n) node_iter = ast.NodeVisitor() - node_iter.visit_FunctionDef = visit_FunctionDef + node_iter.visit_functionDef = visit_functionDef node_iter.visit(ast.parse(inspect.getsource(target))) return decorators