Browse Source

Corrige erros referentes a PEP8

pull/1537/head
Mariana Mendes 7 years ago
parent
commit
e63dfff5fc
  1. 1
      sapl/base/views.py
  2. 1
      sapl/painel/urls.py
  3. 7
      sapl/painel/views.py
  4. 3
      sapl/parlamentares/tests/test_parlamentares.py
  5. 3
      sapl/sessao/models.py
  6. 2
      sapl/sessao/tests/test_sessao.py
  7. 5
      sapl/utils.py
  8. 8
      scripts/lista_permissions_in_decorators.py

1
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

1
sapl/painel/urls.py

@ -25,4 +25,3 @@ urlpatterns = [
url(r'^voto-individual/$', votante_view,
name='voto_individual'),
]

7
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({

3
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'},

3
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'))

2
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,

5
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.
"""

8
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

Loading…
Cancel
Save