Browse Source

fix qa

pull/691/head
LeandroRoberto 8 years ago
parent
commit
abf789778e
  1. 3
      sapl/base/models.py
  2. 2
      sapl/base/templatetags/menus.py
  3. 8
      sapl/comissoes/views.py
  4. 2
      sapl/crispy_layout_mixin.py
  5. 3
      sapl/crud/base.py
  6. 3
      sapl/materia/forms.py
  7. 10
      sapl/materia/views.py
  8. 4
      sapl/norma/views.py
  9. 19
      sapl/sessao/views.py
  10. 6
      sapl/utils.py
  11. 2
      scripts/inicializa_grupos_autorizacoes.py
  12. 6
      scripts/test_inicializa_grupos_autorizacoes.py

3
sapl/base/models.py

@ -7,12 +7,11 @@ from django.contrib.contenttypes.models import ContentType
from django.core import exceptions from django.core import exceptions
from django.db import models, router from django.db import models, router
from django.db.utils import DEFAULT_DB_ALIAS from django.db.utils import DEFAULT_DB_ALIAS
from django.utils.translation import string_concat
from django.utils.translation import ugettext_lazy as _ from django.utils.translation import ugettext_lazy as _
from django.utils.translation import string_concat
from sapl.utils import UF, YES_NO_CHOICES from sapl.utils import UF, YES_NO_CHOICES
TIPO_DOCUMENTO_ADMINISTRATIVO = (('O', _('Ostensivo')), TIPO_DOCUMENTO_ADMINISTRATIVO = (('O', _('Ostensivo')),
('R', _('Restritivo'))) ('R', _('Restritivo')))

2
sapl/base/templatetags/menus.py

@ -19,7 +19,7 @@ def subnav(context, path=None):
Os campos esperados nos arquivos yaml são: Os campos esperados nos arquivos yaml são:
title title
url url
check_permission - opcional. quando usado check_permission - opcional. quando usado
será realizado o teste de permissão para renderizá-lo. será realizado o teste de permissão para renderizá-lo.
""" """
menu = None menu = None

8
sapl/comissoes/views.py

@ -73,11 +73,9 @@ class MateriasTramitacaoListView(ListView):
for materia in materias: for materia in materias:
comissao = materia.tramitacao_set.last( comissao = materia.tramitacao_set.last(
).unidade_tramitacao_destino.comissao ).unidade_tramitacao_destino.comissao
if (comissao and if (comissao and materia not in lista and
materia not in lista and comissao.pk == int(self.kwargs['pk'])):
comissao.pk == int(self.kwargs['pk']) lista.append(materia)
):
lista.append(materia)
return lista return lista
def get_context_data(self, **kwargs): def get_context_data(self, **kwargs):

2
sapl/crispy_layout_mixin.py

@ -1,12 +1,12 @@
from math import ceil from math import ceil
import rtyaml
from crispy_forms.bootstrap import FormActions from crispy_forms.bootstrap import FormActions
from crispy_forms.helper import FormHelper from crispy_forms.helper import FormHelper
from crispy_forms.layout import HTML, Div, Fieldset, Layout, Submit from crispy_forms.layout import HTML, Div, Fieldset, Layout, Submit
from django import template from django import template
from django.utils import formats from django.utils import formats
from django.utils.translation import ugettext as _ from django.utils.translation import ugettext as _
import rtyaml
def heads_and_tails(list_of_lists): def heads_and_tails(list_of_lists):

3
sapl/crud/base.py

@ -13,8 +13,8 @@ from django.db import models
from django.http.response import Http404 from django.http.response import Http404
from django.utils.decorators import classonlymethod from django.utils.decorators import classonlymethod
from django.utils.encoding import force_text from django.utils.encoding import force_text
from django.utils.translation import string_concat
from django.utils.translation import ugettext_lazy as _ from django.utils.translation import ugettext_lazy as _
from django.utils.translation import string_concat
from django.views.generic import (CreateView, DeleteView, DetailView, ListView, from django.views.generic import (CreateView, DeleteView, DetailView, ListView,
UpdateView) UpdateView)
from django.views.generic.base import ContextMixin from django.views.generic.base import ContextMixin
@ -23,7 +23,6 @@ from django.views.generic.list import MultipleObjectMixin
from sapl.crispy_layout_mixin import CrispyLayoutFormMixin, get_field_display from sapl.crispy_layout_mixin import CrispyLayoutFormMixin, get_field_display
from sapl.utils import normalize from sapl.utils import normalize
logger = logging.getLogger(__name__) logger = logging.getLogger(__name__)
ACTION_LIST, ACTION_CREATE, ACTION_DETAIL, ACTION_UPDATE, ACTION_DELETE = \ ACTION_LIST, ACTION_CREATE, ACTION_DETAIL, ACTION_UPDATE, ACTION_DELETE = \

3
sapl/materia/forms.py

@ -1,5 +1,6 @@
from datetime import datetime from datetime import datetime
import django_filters
from crispy_forms.helper import FormHelper from crispy_forms.helper import FormHelper
from crispy_forms.layout import HTML, Button, Column, Fieldset, Layout from crispy_forms.layout import HTML, Button, Column, Fieldset, Layout
from django import forms from django import forms
@ -11,7 +12,6 @@ from django.db import models, transaction
from django.db.models import Max from django.db.models import Max
from django.forms import ModelForm from django.forms import ModelForm
from django.utils.translation import ugettext_lazy as _ from django.utils.translation import ugettext_lazy as _
import django_filters
from sapl.comissoes.models import Comissao from sapl.comissoes.models import Comissao
from sapl.crispy_layout_mixin import form_actions, to_row from sapl.crispy_layout_mixin import form_actions, to_row
@ -27,7 +27,6 @@ from .models import (AcompanhamentoMateria, Anexada, Autor, Autoria,
Numeracao, Proposicao, Relatoria, TipoMateriaLegislativa, Numeracao, Proposicao, Relatoria, TipoMateriaLegislativa,
Tramitacao, UnidadeTramitacao) Tramitacao, UnidadeTramitacao)
ANO_CHOICES = [('', '---------')] + RANGE_ANOS ANO_CHOICES = [('', '---------')] + RANGE_ANOS

10
sapl/materia/views.py

@ -26,10 +26,10 @@ from django_filters.views import FilterView
from sapl.base.models import CasaLegislativa from sapl.base.models import CasaLegislativa
from sapl.compilacao.views import IntegracaoTaView from sapl.compilacao.views import IntegracaoTaView
from sapl.crispy_layout_mixin import SaplFormLayout, form_actions, to_row from sapl.crispy_layout_mixin import SaplFormLayout, form_actions, to_row
from sapl.crud.base import (RP_DETAIL, RP_LIST, Crud, CrudAux, CrudDetailView, from sapl.crud.base import (ACTION_CREATE, ACTION_DELETE, ACTION_DETAIL,
MasterDetailCrud, make_pagination, ACTION_LIST, ACTION_UPDATE, RP_DETAIL, RP_LIST,
ACTION_CREATE, ACTION_UPDATE, ACTION_LIST, Crud, CrudAux, CrudDetailView, MasterDetailCrud,
ACTION_DELETE, ACTION_DETAIL) make_pagination)
from sapl.materia.forms import AnexadaForm, LegislacaoCitadaForm from sapl.materia.forms import AnexadaForm, LegislacaoCitadaForm
from sapl.norma.models import LegislacaoCitada from sapl.norma.models import LegislacaoCitada
from sapl.utils import (TURNO_TRAMITACAO_CHOICES, YES_NO_CHOICES, autor_label, from sapl.utils import (TURNO_TRAMITACAO_CHOICES, YES_NO_CHOICES, autor_label,
@ -52,8 +52,6 @@ from .models import (AcompanhamentoMateria, Anexada, Autor, Autoria,
TipoFimRelatoria, TipoMateriaLegislativa, TipoProposicao, TipoFimRelatoria, TipoMateriaLegislativa, TipoProposicao,
Tramitacao, UnidadeTramitacao) Tramitacao, UnidadeTramitacao)
#AnexadaCrud = Crud.build(Anexada, '')
OrigemCrud = Crud.build(Origem, '') OrigemCrud = Crud.build(Origem, '')
TipoMateriaCrud = CrudAux.build( TipoMateriaCrud = CrudAux.build(

4
sapl/norma/views.py

@ -8,9 +8,7 @@ from sapl.crud.base import RP_DETAIL, RP_LIST, Crud, CrudAux, make_pagination
from sapl.norma.forms import NormaJuridicaForm from sapl.norma.forms import NormaJuridicaForm
from .forms import NormaJuridicaPesquisaForm from .forms import NormaJuridicaPesquisaForm
from .models import (AssuntoNorma, LegislacaoCitada, NormaJuridica, from .models import AssuntoNorma, NormaJuridica, TipoNormaJuridica
TipoNormaJuridica)
# LegislacaoCitadaCrud = Crud.build(LegislacaoCitada, '') # LegislacaoCitadaCrud = Crud.build(LegislacaoCitada, '')

19
sapl/sessao/views.py

@ -2,8 +2,6 @@ from datetime import datetime
from re import sub from re import sub
from django.contrib import messages from django.contrib import messages
from django.contrib.auth.decorators import permission_required
from django.contrib.auth.mixins import PermissionRequiredMixin
from django.core.exceptions import ObjectDoesNotExist, ValidationError from django.core.exceptions import ObjectDoesNotExist, ValidationError
from django.core.urlresolvers import reverse from django.core.urlresolvers import reverse
from django.forms.utils import ErrorList from django.forms.utils import ErrorList
@ -21,8 +19,8 @@ from rest_framework import generics
from sapl.base.models import AppConfig as AppsAppConfig from sapl.base.models import AppConfig as AppsAppConfig
from sapl.crud.base import (RP_DETAIL, RP_LIST, Crud, CrudAux, from sapl.crud.base import (RP_DETAIL, RP_LIST, Crud, CrudAux,
MasterDetailCrud, make_pagination, MasterDetailCrud,
PermissionRequiredForAppCrudMixin) PermissionRequiredForAppCrudMixin, make_pagination)
from sapl.materia.forms import pega_ultima_tramitacao from sapl.materia.forms import pega_ultima_tramitacao
from sapl.materia.models import (Autoria, DocumentoAcessorio, from sapl.materia.models import (Autoria, DocumentoAcessorio,
TipoMateriaLegislativa, Tramitacao) TipoMateriaLegislativa, Tramitacao)
@ -33,7 +31,7 @@ from sapl.parlamentares.models import (Legislatura, Parlamentar,
from sapl.sessao.apps import AppConfig from sapl.sessao.apps import AppConfig
from sapl.sessao.forms import ExpedienteMateriaForm, OrdemDiaForm from sapl.sessao.forms import ExpedienteMateriaForm, OrdemDiaForm
from sapl.sessao.serializers import SessaoPlenariaSerializer from sapl.sessao.serializers import SessaoPlenariaSerializer
from sapl.utils import permissoes_painel, permission_required_for_app from sapl.utils import permission_required_for_app
from .forms import (AdicionarVariasMateriasFilterSet, ExpedienteForm, from .forms import (AdicionarVariasMateriasFilterSet, ExpedienteForm,
ListMateriaForm, MesaForm, PautaSessaoFilterSet, ListMateriaForm, MesaForm, PautaSessaoFilterSet,
@ -46,9 +44,8 @@ from .models import (Bancada, Bloco, CargoBancada, CargoMesa,
SessaoPlenariaPresenca, TipoExpediente, SessaoPlenariaPresenca, TipoExpediente,
TipoResultadoVotacao, TipoSessaoPlenaria, VotoParlamentar) TipoResultadoVotacao, TipoSessaoPlenaria, VotoParlamentar)
# OrdemDiaCrud = Crud.build(OrdemDia, '')
#OrdemDiaCrud = Crud.build(OrdemDia, '') # RegistroVotacaoCrud = Crud.build(RegistroVotacao, '')
#RegistroVotacaoCrud = Crud.build(RegistroVotacao, '')
TipoSessaoCrud = CrudAux.build(TipoSessaoPlenaria, 'tipo_sessao_plenaria') TipoSessaoCrud = CrudAux.build(TipoSessaoPlenaria, 'tipo_sessao_plenaria')
TipoExpedienteCrud = CrudAux.build(TipoExpediente, 'tipo_expediente') TipoExpedienteCrud = CrudAux.build(TipoExpediente, 'tipo_expediente')
CargoBancadaCrud = CrudAux.build(CargoBancada, '') CargoBancadaCrud = CrudAux.build(CargoBancada, '')
@ -181,9 +178,9 @@ class MateriaOrdemDiaCrud(MasterDetailCrud):
'mid': obj.pk}) 'mid': obj.pk})
if self.request.user.has_module_perms(AppConfig.label): if self.request.user.has_module_perms(AppConfig.label):
btn_registrar = ''' btn_registrar = '''
<a href="%s" <a href="%s"
class="btn btn-primary" class="btn btn-primary"
role="button">Registrar Votação</a>''' % ( role="button">Registrar Votação</a>''' % (
url) url)
obj.resultado = btn_registrar obj.resultado = btn_registrar
else: else:

6
sapl/utils.py

@ -1,8 +1,9 @@
import hashlib
from datetime import date from datetime import date
from functools import wraps from functools import wraps
from unicodedata import normalize as unicodedata_normalize from unicodedata import normalize as unicodedata_normalize
import hashlib
import magic
from django import forms from django import forms
from django.apps import apps from django.apps import apps
from django.conf import settings from django.conf import settings
@ -10,10 +11,9 @@ from django.contrib import admin
from django.contrib.auth.decorators import user_passes_test from django.contrib.auth.decorators import user_passes_test
from django.contrib.auth.models import Permission from django.contrib.auth.models import Permission
from django.contrib.contenttypes.models import ContentType from django.contrib.contenttypes.models import ContentType
from django.core.exceptions import ValidationError, PermissionDenied from django.core.exceptions import PermissionDenied, ValidationError
from django.utils.translation import ugettext_lazy as _ from django.utils.translation import ugettext_lazy as _
from floppyforms import ClearableFileInput from floppyforms import ClearableFileInput
import magic
def normalize(txt): def normalize(txt):

2
scripts/inicializa_grupos_autorizacoes.py

@ -1,6 +1,6 @@
import os import os
import django
import django
os.environ.setdefault("DJANGO_SETTINGS_MODULE", "sapl.settings") os.environ.setdefault("DJANGO_SETTINGS_MODULE", "sapl.settings")
django.setup() django.setup()

6
scripts/test_inicializa_grupos_autorizacoes.py

@ -1,16 +1,14 @@
import pytest
from django.apps import apps from django.apps import apps
from django.contrib.auth.management import _get_all_permissions from django.contrib.auth.management import _get_all_permissions
from django.contrib.auth.models import Group, Permission from django.contrib.auth.models import Group, Permission
from django.contrib.contenttypes.models import ContentType from django.contrib.contenttypes.models import ContentType
from django.core.exceptions import ValidationError
from django.utils.encoding import force_text from django.utils.encoding import force_text
from django.utils.translation import string_concat
from django.utils.translation import ugettext_lazy as _ from django.utils.translation import ugettext_lazy as _
import pytest from django.utils.translation import string_concat
from inicializa_grupos_autorizacoes import cria_grupos_permissoes from inicializa_grupos_autorizacoes import cria_grupos_permissoes
pytestmark = pytest.mark.django_db pytestmark = pytest.mark.django_db
apps_com_permissao_padrao = [ apps_com_permissao_padrao = [

Loading…
Cancel
Save