Browse Source

Ajusta código para QA script

pull/979/head
Edward Ribeiro 8 years ago
parent
commit
3b0a0dc37b
  1. 2
      sapl/compilacao/views.py
  2. 19
      sapl/materia/forms.py
  3. 1
      sapl/materia/models.py
  4. 7
      sapl/materia/views.py
  5. 6
      sapl/norma/views.py
  6. 2
      sapl/parlamentares/forms.py
  7. 1
      sapl/parlamentares/models.py
  8. 4
      sapl/parlamentares/tests/test_parlamentares.py
  9. 10
      sapl/parlamentares/views.py
  10. 2
      sapl/protocoloadm/forms.py
  11. 3
      sapl/protocoloadm/views.py
  12. 1
      sapl/sessao/models.py
  13. 9
      sapl/sessao/views.py
  14. 1
      sapl/utils.py

2
sapl/compilacao/views.py

@ -1,7 +1,7 @@
import logging import logging
import sys import sys
from collections import OrderedDict from collections import OrderedDict
from datetime import datetime, timedelta from datetime import timedelta
from braces.views import FormMessagesMixin from braces.views import FormMessagesMixin
from django import forms from django import forms

19
sapl/materia/forms.py

@ -26,16 +26,13 @@ import sapl
from sapl.base.models import Autor from sapl.base.models import Autor
from sapl.comissoes.models import Comissao from sapl.comissoes.models import Comissao
from sapl.compilacao.models import (STATUS_TA_IMMUTABLE_PUBLIC, from sapl.compilacao.models import (STATUS_TA_IMMUTABLE_PUBLIC,
STATUS_TA_PRIVATE, STATUS_TA_PUBLIC, STATUS_TA_PRIVATE)
PerfilEstruturalTextoArticulado,
TextoArticulado)
from sapl.crispy_layout_mixin import (SaplFormLayout, form_actions, to_column, from sapl.crispy_layout_mixin import (SaplFormLayout, form_actions, to_column,
to_row) to_row)
from sapl.materia.models import (MateriaLegislativa, RegimeTramitacao, from sapl.materia.models import (MateriaLegislativa, RegimeTramitacao,
TipoDocumento, TipoProposicao) TipoDocumento, TipoProposicao)
from sapl.norma.models import (LegislacaoCitada, NormaJuridica, from sapl.norma.models import (LegislacaoCitada, NormaJuridica,
TipoNormaJuridica) TipoNormaJuridica)
from sapl.parlamentares.models import Parlamentar
from sapl.protocoloadm.models import Protocolo from sapl.protocoloadm.models import Protocolo
from sapl.settings import MAX_DOC_UPLOAD_SIZE from sapl.settings import MAX_DOC_UPLOAD_SIZE
from sapl.utils import (RANGE_ANOS, YES_NO_CHOICES, from sapl.utils import (RANGE_ANOS, YES_NO_CHOICES,
@ -780,7 +777,8 @@ class TipoProposicaoForm(ModelForm):
tipo_select = Fieldset(TipoProposicao._meta.verbose_name, tipo_select = Fieldset(TipoProposicao._meta.verbose_name,
Div(to_column(('descricao', 5)), 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(('tipo_conteudo_related_radio', 6)),
to_column(('perfis', 6))) to_column(('perfis', 6)))
@ -847,11 +845,12 @@ class TipoProposicaoSelect(Select):
selected_choices.remove(option_value) selected_choices.remove(option_value)
else: else:
selected_html = '' selected_html = ''
return format_html('<option value="{}"{} data-has-perfil={}>{}</option>', return format_html(
option_value, '<option value="{}"{} data-has-perfil={}>{}</option>',
selected_html, option_value,
str(data_has_perfil), selected_html,
force_text(option_label)) str(data_has_perfil),
force_text(option_label))
def render_options(self, choices, selected_choices): def render_options(self, choices, selected_choices):
# Normalize to strings. # Normalize to strings.

1
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.fields import GenericRelation
from django.contrib.contenttypes.models import ContentType from django.contrib.contenttypes.models import ContentType
from django.db import models from django.db import models
from django.db.models.deletion import PROTECT
from django.utils import formats from django.utils import formats
from django.utils.translation import ugettext_lazy as _ from django.utils.translation import ugettext_lazy as _
from model_utils import Choices from model_utils import Choices

7
sapl/materia/views.py

@ -24,8 +24,7 @@ from django_filters.views import FilterView
import sapl import sapl
from sapl.base.models import Autor, CasaLegislativa from sapl.base.models import Autor, CasaLegislativa
from sapl.comissoes.models import Comissao, Participacao from sapl.comissoes.models import Comissao, Participacao
from sapl.compilacao.models import (STATUS_TA_EDITION, from sapl.compilacao.models import (STATUS_TA_IMMUTABLE_RESTRICT,
STATUS_TA_IMMUTABLE_RESTRICT,
STATUS_TA_PRIVATE) STATUS_TA_PRIVATE)
from sapl.compilacao.views import IntegracaoTaView from sapl.compilacao.views import IntegracaoTaView
from sapl.crispy_layout_mixin import SaplFormLayout, form_actions from sapl.crispy_layout_mixin import SaplFormLayout, form_actions
@ -37,7 +36,6 @@ from sapl.materia.forms import (AnexadaForm, ConfirmarProposicaoForm,
LegislacaoCitadaForm, ProposicaoForm, LegislacaoCitadaForm, ProposicaoForm,
TipoProposicaoForm) TipoProposicaoForm)
from sapl.norma.models import LegislacaoCitada from sapl.norma.models import LegislacaoCitada
from sapl.parlamentares.models import Parlamentar
from sapl.protocoloadm.models import Protocolo from sapl.protocoloadm.models import Protocolo
from sapl.utils import (TURNO_TRAMITACAO_CHOICES, YES_NO_CHOICES, autor_label, from sapl.utils import (TURNO_TRAMITACAO_CHOICES, YES_NO_CHOICES, autor_label,
autor_modal, gerar_hash_arquivo, get_base_url, autor_modal, gerar_hash_arquivo, get_base_url,
@ -417,7 +415,8 @@ class ReceberProposicao(PermissionRequiredForAppCrudMixin, FormView):
else: else:
hasher = gerar_hash_arquivo( hasher = gerar_hash_arquivo(
proposicao.texto_original.path, 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']: if hasher == form.cleaned_data['cod_hash']:
return HttpResponseRedirect( return HttpResponseRedirect(
reverse('sapl.materia:proposicao-confirmar', reverse('sapl.materia:proposicao-confirmar',

6
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.core.urlresolvers import reverse
from django.http import JsonResponse from django.http import JsonResponse
from django.shortcuts import redirect
from django.utils.translation import ugettext_lazy as _ from django.utils.translation import ugettext_lazy as _
from django.views.generic import FormView, ListView
from django.views.generic.base import RedirectView from django.views.generic.base import RedirectView
from django_filters.views import FilterView from django_filters.views import FilterView
from sapl.base.models import AppConfig from sapl.base.models import AppConfig
from sapl.compilacao.views import IntegracaoTaView from sapl.compilacao.views import IntegracaoTaView
from sapl.crud.base import (RP_DETAIL, RP_LIST, Crud, CrudAux, from sapl.crud.base import (RP_DETAIL, RP_LIST, Crud, CrudAux,

2
sapl/parlamentares/forms.py

@ -62,7 +62,7 @@ class MandatoForm(ModelForm):
data = self.cleaned_data data = self.cleaned_data
try: try:
if 'legislatura' in data and 'parlamentar' in data: if 'legislatura' in data and 'parlamentar' in data:
mandato = Mandato.objects.get( Mandato.objects.get(
parlamentar__pk=self.initial['parlamentar'].pk, parlamentar__pk=self.initial['parlamentar'].pk,
legislatura__pk=data['legislatura'].pk) legislatura__pk=data['legislatura'].pk)
except ObjectDoesNotExist: except ObjectDoesNotExist:

1
sapl/parlamentares/models.py

@ -1,7 +1,6 @@
from datetime import datetime from datetime import datetime
import reversion import reversion
from django.contrib.auth.models import User
from django.db import models from django.db import models
from django.utils.translation import ugettext_lazy as _ from django.utils.translation import ugettext_lazy as _
from model_utils import Choices from model_utils import Choices

4
sapl/parlamentares/tests/test_parlamentares.py

@ -122,9 +122,9 @@ def test_mandato_submit(admin_client):
mommy.make(Parlamentar, pk=14) mommy.make(Parlamentar, pk=14)
mommy.make(Legislatura, pk=5) 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}), kwargs={'pk': 14}),
{'parlamentar': 14, # hidden field {'parlamentar': 14, # hidden field
'legislatura': 5, 'legislatura': 5,
'data_fim_mandato': '2016-01-01', 'data_fim_mandato': '2016-01-01',
'data_expedicao_diploma': '2016-03-22', 'data_expedicao_diploma': '2016-03-22',

10
sapl/parlamentares/views.py

@ -266,7 +266,11 @@ class ParlamentarCrud(Crud):
class BaseMixin(Crud.BaseMixin): class BaseMixin(Crud.BaseMixin):
ordered_list = False ordered_list = False
list_field_names = [ 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): class DetailView(Crud.DetailView):
@ -327,7 +331,9 @@ class ParlamentarCrud(Crud):
mandato_titular=F('mandato__titular')) mandato_titular=F('mandato__titular'))
def get_headers(self): def get_headers(self):
return ['', _('Parlamentar'), _('Partido'), _('Ativo?'), _('Titular?')] return ['',
_('Parlamentar'), _('Partido'),
_('Ativo?'), _('Titular?')]
def get_context_data(self, **kwargs): def get_context_data(self, **kwargs):
context = super().get_context_data(**kwargs) context = super().get_context_data(**kwargs)

2
sapl/protocoloadm/forms.py

@ -547,7 +547,7 @@ class DocumentoAdministrativoForm(ModelForm):
get_field('ano').verbose_name, get_field('ano').verbose_name,
choices=RANGE_ANOS, choices=RANGE_ANOS,
widget=forms.Select( widget=forms.Select(
attrs={'class': 'selector'})) attrs={'class': 'selector'}))
class Meta: class Meta:
model = DocumentoAdministrativo model = DocumentoAdministrativo

3
sapl/protocoloadm/views.py

@ -341,7 +341,8 @@ class ProtocoloMostrarView(PermissionRequiredMixin, TemplateView):
if protocolo.tipo_documento: if protocolo.tipo_documento:
context[ context[
'documentos'] = protocolo.documentoadministrativo_set.all().order_by('-ano', '-numero') 'documentos'] = protocolo.documentoadministrativo_set\
.all().order_by('-ano', '-numero')
context['protocolo'] = protocolo context['protocolo'] = protocolo
return context return context

1
sapl/sessao/models.py

@ -1,5 +1,4 @@
import reversion import reversion
from django.contrib.auth.models import User
from django.db import models from django.db import models
from django.utils.translation import ugettext_lazy as _ from django.utils.translation import ugettext_lazy as _
from model_utils import Choices from model_utils import Choices

9
sapl/sessao/views.py

@ -603,9 +603,11 @@ class PainelView(PermissionRequiredForAppCrudMixin, TemplateView):
cronometro_aparte = AppsAppConfig.attr('cronometro_aparte') cronometro_aparte = AppsAppConfig.attr('cronometro_aparte')
cronometro_ordem = AppsAppConfig.attr('cronometro_ordem') 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 = _( 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) messages.add_message(self.request, messages.ERROR, msg)
else: else:
@ -2419,7 +2421,7 @@ def mudar_ordem_materia_sessao(request):
pk_list = request.POST.getlist('pk_list[]') pk_list = request.POST.getlist('pk_list[]')
materia = request.POST['materia'] materia = request.POST['materia']
# Verifica se está nas Matérias do Expediente ou da Ordem do Dia # Verifica se está nas Matérias do Expediente ou da Ordem do Dia
if materia == 'expediente': if materia == 'expediente':
materia = ExpedienteMateria materia = ExpedienteMateria
@ -2448,7 +2450,6 @@ def mudar_ordem_materia_sessao(request):
m.numero_ordem = m.numero_ordem - 1 m.numero_ordem = m.numero_ordem - 1
m.save() m.save()
# Se a posição inicial for maior que a final, todos que # Se a posição inicial for maior que a final, todos que
# estiverem abaixo da nova posição devem ter sua ordem incrementada # estiverem abaixo da nova posição devem ter sua ordem incrementada
# em uma posição # em uma posição

1
sapl/utils.py

@ -16,7 +16,6 @@ from django.contrib import admin
from django.contrib.contenttypes.fields import (GenericForeignKey, GenericRel, from django.contrib.contenttypes.fields import (GenericForeignKey, GenericRel,
GenericRelation) GenericRelation)
from django.core.exceptions import ValidationError from django.core.exceptions import ValidationError
from django.utils.text import slugify
from django.utils.translation import ugettext_lazy as _ from django.utils.translation import ugettext_lazy as _
from floppyforms import ClearableFileInput from floppyforms import ClearableFileInput
from reversion.admin import VersionAdmin from reversion.admin import VersionAdmin

Loading…
Cancel
Save