diff --git a/sapl/compilacao/views.py b/sapl/compilacao/views.py index 2dc8f688c..142b7f46d 100644 --- a/sapl/compilacao/views.py +++ b/sapl/compilacao/views.py @@ -1,7 +1,7 @@ import logging import sys from collections import OrderedDict -from datetime import datetime, timedelta +from datetime import timedelta from braces.views import FormMessagesMixin from django import forms diff --git a/sapl/materia/forms.py b/sapl/materia/forms.py index 951a8ed7c..e1fda4119 100644 --- a/sapl/materia/forms.py +++ b/sapl/materia/forms.py @@ -26,16 +26,13 @@ import sapl from sapl.base.models import Autor from sapl.comissoes.models import Comissao from sapl.compilacao.models import (STATUS_TA_IMMUTABLE_PUBLIC, - STATUS_TA_PRIVATE, STATUS_TA_PUBLIC, - PerfilEstruturalTextoArticulado, - TextoArticulado) + STATUS_TA_PRIVATE) from sapl.crispy_layout_mixin import (SaplFormLayout, form_actions, to_column, to_row) from sapl.materia.models import (MateriaLegislativa, RegimeTramitacao, TipoDocumento, TipoProposicao) from sapl.norma.models import (LegislacaoCitada, NormaJuridica, TipoNormaJuridica) -from sapl.parlamentares.models import Parlamentar from sapl.protocoloadm.models import Protocolo from sapl.settings import MAX_DOC_UPLOAD_SIZE from sapl.utils import (RANGE_ANOS, YES_NO_CHOICES, @@ -780,7 +777,8 @@ class TipoProposicaoForm(ModelForm): tipo_select = Fieldset(TipoProposicao._meta.verbose_name, Div(to_column(('descricao', 5)), - to_column(('content_type', 7)), css_class='clearfix'), + to_column(('content_type', 7)), + css_class='clearfix'), to_column(('tipo_conteudo_related_radio', 6)), to_column(('perfis', 6))) @@ -847,11 +845,12 @@ class TipoProposicaoSelect(Select): selected_choices.remove(option_value) else: selected_html = '' - return format_html('', - option_value, - selected_html, - str(data_has_perfil), - force_text(option_label)) + return format_html( + '', + option_value, + selected_html, + str(data_has_perfil), + force_text(option_label)) def render_options(self, choices, selected_choices): # Normalize to strings. diff --git a/sapl/materia/models.py b/sapl/materia/models.py index bbffb6d45..372efadf0 100644 --- a/sapl/materia/models.py +++ b/sapl/materia/models.py @@ -5,7 +5,6 @@ from django.contrib.auth.models import Group from django.contrib.contenttypes.fields import GenericRelation from django.contrib.contenttypes.models import ContentType from django.db import models -from django.db.models.deletion import PROTECT from django.utils import formats from django.utils.translation import ugettext_lazy as _ from model_utils import Choices diff --git a/sapl/materia/views.py b/sapl/materia/views.py index 8a401b079..e8331e469 100644 --- a/sapl/materia/views.py +++ b/sapl/materia/views.py @@ -24,8 +24,7 @@ from django_filters.views import FilterView import sapl from sapl.base.models import Autor, CasaLegislativa from sapl.comissoes.models import Comissao, Participacao -from sapl.compilacao.models import (STATUS_TA_EDITION, - STATUS_TA_IMMUTABLE_RESTRICT, +from sapl.compilacao.models import (STATUS_TA_IMMUTABLE_RESTRICT, STATUS_TA_PRIVATE) from sapl.compilacao.views import IntegracaoTaView from sapl.crispy_layout_mixin import SaplFormLayout, form_actions @@ -37,7 +36,6 @@ from sapl.materia.forms import (AnexadaForm, ConfirmarProposicaoForm, LegislacaoCitadaForm, ProposicaoForm, TipoProposicaoForm) from sapl.norma.models import LegislacaoCitada -from sapl.parlamentares.models import Parlamentar from sapl.protocoloadm.models import Protocolo from sapl.utils import (TURNO_TRAMITACAO_CHOICES, YES_NO_CHOICES, autor_label, autor_modal, gerar_hash_arquivo, get_base_url, @@ -417,7 +415,8 @@ class ReceberProposicao(PermissionRequiredForAppCrudMixin, FormView): else: hasher = gerar_hash_arquivo( proposicao.texto_original.path, - str(proposicao.pk)) if proposicao.texto_original else None + str(proposicao.pk)) \ + if proposicao.texto_original else None if hasher == form.cleaned_data['cod_hash']: return HttpResponseRedirect( reverse('sapl.materia:proposicao-confirmar', diff --git a/sapl/norma/views.py b/sapl/norma/views.py index 10dbf4ad2..461c1b9ef 100644 --- a/sapl/norma/views.py +++ b/sapl/norma/views.py @@ -1,13 +1,9 @@ -from datetime import datetime - +from django.core.exceptions import ObjectDoesNotExist from django.core.urlresolvers import reverse from django.http import JsonResponse -from django.shortcuts import redirect from django.utils.translation import ugettext_lazy as _ -from django.views.generic import FormView, ListView from django.views.generic.base import RedirectView 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/parlamentares/forms.py b/sapl/parlamentares/forms.py index cd70ca995..9e2b26b59 100644 --- a/sapl/parlamentares/forms.py +++ b/sapl/parlamentares/forms.py @@ -62,7 +62,7 @@ class MandatoForm(ModelForm): data = self.cleaned_data try: if 'legislatura' in data and 'parlamentar' in data: - mandato = Mandato.objects.get( + Mandato.objects.get( parlamentar__pk=self.initial['parlamentar'].pk, legislatura__pk=data['legislatura'].pk) except ObjectDoesNotExist: diff --git a/sapl/parlamentares/models.py b/sapl/parlamentares/models.py index 1152b94df..d09f8dfac 100644 --- a/sapl/parlamentares/models.py +++ b/sapl/parlamentares/models.py @@ -1,7 +1,6 @@ from datetime import datetime import reversion -from django.contrib.auth.models import User from django.db import models from django.utils.translation import ugettext_lazy as _ from model_utils import Choices diff --git a/sapl/parlamentares/tests/test_parlamentares.py b/sapl/parlamentares/tests/test_parlamentares.py index 6881b7a18..b71816d5b 100644 --- a/sapl/parlamentares/tests/test_parlamentares.py +++ b/sapl/parlamentares/tests/test_parlamentares.py @@ -122,9 +122,9 @@ def test_mandato_submit(admin_client): mommy.make(Parlamentar, pk=14) mommy.make(Legislatura, pk=5) - response = admin_client.post(reverse('sapl.parlamentares:mandato_create', + admin_client.post(reverse('sapl.parlamentares:mandato_create', kwargs={'pk': 14}), - {'parlamentar': 14, # hidden field + {'parlamentar': 14, # hidden field 'legislatura': 5, 'data_fim_mandato': '2016-01-01', 'data_expedicao_diploma': '2016-03-22', diff --git a/sapl/parlamentares/views.py b/sapl/parlamentares/views.py index 0f7f0ee70..a4f698b5a 100644 --- a/sapl/parlamentares/views.py +++ b/sapl/parlamentares/views.py @@ -266,7 +266,11 @@ class ParlamentarCrud(Crud): class BaseMixin(Crud.BaseMixin): ordered_list = False list_field_names = [ - 'avatar_html', 'nome_parlamentar', 'filiacao_atual', 'ativo', 'mandato_titular'] + 'avatar_html', + 'nome_parlamentar', + 'filiacao_atual', + 'ativo', + 'mandato_titular'] class DetailView(Crud.DetailView): @@ -327,7 +331,9 @@ class ParlamentarCrud(Crud): mandato_titular=F('mandato__titular')) def get_headers(self): - return ['', _('Parlamentar'), _('Partido'), _('Ativo?'), _('Titular?')] + return ['', + _('Parlamentar'), _('Partido'), + _('Ativo?'), _('Titular?')] def get_context_data(self, **kwargs): context = super().get_context_data(**kwargs) diff --git a/sapl/protocoloadm/forms.py b/sapl/protocoloadm/forms.py index 1caf5c569..bca51df31 100644 --- a/sapl/protocoloadm/forms.py +++ b/sapl/protocoloadm/forms.py @@ -547,7 +547,7 @@ class DocumentoAdministrativoForm(ModelForm): get_field('ano').verbose_name, choices=RANGE_ANOS, widget=forms.Select( - attrs={'class': 'selector'})) + attrs={'class': 'selector'})) class Meta: model = DocumentoAdministrativo diff --git a/sapl/protocoloadm/views.py b/sapl/protocoloadm/views.py index 3e13920d4..9505f3bd9 100644 --- a/sapl/protocoloadm/views.py +++ b/sapl/protocoloadm/views.py @@ -341,7 +341,8 @@ class ProtocoloMostrarView(PermissionRequiredMixin, TemplateView): if protocolo.tipo_documento: context[ - 'documentos'] = protocolo.documentoadministrativo_set.all().order_by('-ano', '-numero') + 'documentos'] = protocolo.documentoadministrativo_set\ + .all().order_by('-ano', '-numero') context['protocolo'] = protocolo return context diff --git a/sapl/sessao/models.py b/sapl/sessao/models.py index 33b2c73ad..e308b4187 100644 --- a/sapl/sessao/models.py +++ b/sapl/sessao/models.py @@ -1,5 +1,4 @@ import reversion -from django.contrib.auth.models import User from django.db import models from django.utils.translation import ugettext_lazy as _ from model_utils import Choices diff --git a/sapl/sessao/views.py b/sapl/sessao/views.py index 928e5f746..372cbff7e 100644 --- a/sapl/sessao/views.py +++ b/sapl/sessao/views.py @@ -603,9 +603,11 @@ class PainelView(PermissionRequiredForAppCrudMixin, TemplateView): cronometro_aparte = AppsAppConfig.attr('cronometro_aparte') cronometro_ordem = AppsAppConfig.attr('cronometro_ordem') - if not cronometro_discurso or not cronometro_aparte or not cronometro_ordem: + if (not cronometro_discurso or not cronometro_aparte + or not cronometro_ordem): msg = _( - 'Você precisa primeiro configurar os cronômetros nas Configurações da Aplicação') + 'Você precisa primeiro configurar os cronômetros \ + nas Configurações da Aplicação') messages.add_message(self.request, messages.ERROR, msg) else: @@ -2419,7 +2421,7 @@ def mudar_ordem_materia_sessao(request): pk_list = request.POST.getlist('pk_list[]') materia = request.POST['materia'] - + # Verifica se está nas Matérias do Expediente ou da Ordem do Dia if materia == 'expediente': materia = ExpedienteMateria @@ -2448,7 +2450,6 @@ def mudar_ordem_materia_sessao(request): m.numero_ordem = m.numero_ordem - 1 m.save() - # Se a posição inicial for maior que a final, todos que # estiverem abaixo da nova posição devem ter sua ordem incrementada # em uma posição diff --git a/sapl/utils.py b/sapl/utils.py index 09902fae9..d957add71 100644 --- a/sapl/utils.py +++ b/sapl/utils.py @@ -16,7 +16,6 @@ from django.contrib import admin from django.contrib.contenttypes.fields import (GenericForeignKey, GenericRel, GenericRelation) from django.core.exceptions import ValidationError -from django.utils.text import slugify from django.utils.translation import ugettext_lazy as _ from floppyforms import ClearableFileInput from reversion.admin import VersionAdmin