Browse Source

Fix qa

pull/754/head
Eduardo Edson Batista Cordeiro Alves 8 years ago
parent
commit
62c5a640b0
  1. 4
      sapl/api/forms.py
  2. 1
      sapl/api/pagination.py
  3. 2
      sapl/api/serializers.py
  4. 3
      sapl/api/urls.py
  5. 7
      sapl/api/views.py
  6. 14
      sapl/base/forms.py
  7. 3
      sapl/base/templatetags/menus.py
  8. 2
      sapl/base/urls.py
  9. 4
      sapl/base/views.py
  10. 2
      sapl/comissoes/views.py
  11. 7
      sapl/compilacao/views.py
  12. 5
      sapl/crud/base.py
  13. 10
      sapl/materia/forms.py
  14. 2
      sapl/materia/models.py
  15. 4
      sapl/materia/tests/test_materia.py
  16. 5
      sapl/materia/urls.py
  17. 7
      sapl/materia/views.py
  18. 5
      sapl/parlamentares/views.py
  19. 3
      sapl/protocoloadm/forms.py
  20. 3
      sapl/protocoloadm/models.py
  21. 14
      sapl/protocoloadm/views.py
  22. 2
      sapl/relatorios/views.py
  23. 4
      sapl/sessao/models.py
  24. 1
      sapl/sessao/views.py
  25. 3
      sapl/settings.py
  26. 7
      sapl/test_urls.py
  27. 16
      sapl/utils.py
  28. 1
      scripts/inicializa_grupos_autorizacoes.py

4
sapl/api/forms.py

@ -1,11 +1,9 @@
from django.contrib.contenttypes.fields import GenericRel
from django.db.models import Q from django.db.models import Q
from django_filters.filters import MethodFilter, ModelChoiceFilter from django_filters.filters import MethodFilter, ModelChoiceFilter
from rest_framework.filters import FilterSet from rest_framework.filters import FilterSet
from sapl.base.forms import autores_models_generic_relations from sapl.base.forms import autores_models_generic_relations
from sapl.base.models import Autor, TipoAutor from sapl.base.models import Autor, TipoAutor
from sapl.utils import SaplGenericRelation
class AutorChoiceFilterSet(FilterSet): class AutorChoiceFilterSet(FilterSet):
@ -31,7 +29,7 @@ class AutorChoiceFilterSet(FilterSet):
order_by = [] order_by = []
for gr in autores_models_generic_relations(): for gr in autores_models_generic_relations():
model = gr[0] # model = gr[0]
sgr = gr[1] sgr = gr[1]
for item in sgr: for item in sgr:
if item.related_model != Autor: if item.related_model != Autor:

1
sapl/api/pagination.py

@ -1,5 +1,4 @@
from django.core.paginator import EmptyPage from django.core.paginator import EmptyPage
from django.utils.encoding import force_text
from rest_framework import pagination from rest_framework import pagination
from rest_framework.response import Response from rest_framework.response import Response

2
sapl/api/serializers.py

@ -1,8 +1,6 @@
from django.contrib.contenttypes.fields import GenericRel
from rest_framework import serializers from rest_framework import serializers
from sapl.base.models import Autor from sapl.base.models import Autor
from sapl.utils import SaplGenericRelation
class ChoiceSerializer(serializers.Serializer): class ChoiceSerializer(serializers.Serializer):

3
sapl/api/urls.py

@ -1,11 +1,10 @@
from django.conf import settings from django.conf import settings
from django.conf.urls import url, include from django.conf.urls import include, url
from sapl.api.views import AutorListView from sapl.api.views import AutorListView
from .apps import AppConfig from .apps import AppConfig
app_name = AppConfig.name app_name = AppConfig.name

7
sapl/api/views.py

@ -1,14 +1,13 @@
from django.db.models import Q from django.db.models import Q
from django.http import Http404 from django.http import Http404
from django.utils.translation import ugettext_lazy as _ from django.utils.translation import ugettext_lazy as _
from rest_framework.filters import DjangoFilterBackend from rest_framework.filters import DjangoFilterBackend
from rest_framework.generics import ListAPIView from rest_framework.generics import ListAPIView
from rest_framework.permissions import IsAuthenticated, AllowAny from rest_framework.permissions import AllowAny, IsAuthenticated
from sapl.api.forms import AutorChoiceFilterSet from sapl.api.forms import AutorChoiceFilterSet
from sapl.api.serializers import ChoiceSerializer, AutorSerializer,\ from sapl.api.serializers import (AutorChoiceSerializer, AutorSerializer,
AutorChoiceSerializer ChoiceSerializer)
from sapl.base.models import Autor, TipoAutor from sapl.base.models import Autor, TipoAutor
from sapl.utils import SaplGenericRelation, sapl_logger from sapl.utils import SaplGenericRelation, sapl_logger

14
sapl/base/forms.py

@ -1,7 +1,7 @@
import django_filters
from crispy_forms.bootstrap import FieldWithButtons, InlineRadios, StrictButton from crispy_forms.bootstrap import FieldWithButtons, InlineRadios, StrictButton
from crispy_forms.helper import FormHelper from crispy_forms.helper import FormHelper
from crispy_forms.layout import HTML, Button, Div, Field, Fieldset, Layout, Row from crispy_forms.layout import HTML, Button, Div, Field, Fieldset, Layout, Row
from crispy_forms.templatetags.crispy_forms_field import css_class
from django import forms from django import forms
from django.conf import settings from django.conf import settings
from django.contrib.auth import get_user_model from django.contrib.auth import get_user_model
@ -13,8 +13,8 @@ from django.contrib.contenttypes.models import ContentType
from django.core.exceptions import ValidationError from django.core.exceptions import ValidationError
from django.db import models, transaction from django.db import models, transaction
from django.forms import ModelForm from django.forms import ModelForm
from django.utils.translation import ugettext_lazy as _, string_concat from django.utils.translation import ugettext_lazy as _
import django_filters from django.utils.translation import string_concat
from sapl.base.models import Autor, TipoAutor from sapl.base.models import Autor, TipoAutor
from sapl.crispy_layout_mixin import (SaplFormLayout, form_actions, to_column, from sapl.crispy_layout_mixin import (SaplFormLayout, form_actions, to_column,
@ -23,12 +23,11 @@ from sapl.materia.models import MateriaLegislativa
from sapl.sessao.models import SessaoPlenaria from sapl.sessao.models import SessaoPlenaria
from sapl.settings import MAX_IMAGE_UPLOAD_SIZE from sapl.settings import MAX_IMAGE_UPLOAD_SIZE
from sapl.utils import (RANGE_ANOS, ImageThumbnailFileInput, from sapl.utils import (RANGE_ANOS, ImageThumbnailFileInput,
RangeWidgetOverride, autor_label, autor_modal, RangeWidgetOverride, SaplGenericRelation, autor_label,
SaplGenericRelation) autor_modal)
from .models import AppConfig, CasaLegislativa from .models import AppConfig, CasaLegislativa
ACTION_CREATE_USERS_AUTOR_CHOICE = [ ACTION_CREATE_USERS_AUTOR_CHOICE = [
('C', _('Criar novo Usuário')), ('C', _('Criar novo Usuário')),
('A', _('Associar um usuário existente')), ('A', _('Associar um usuário existente')),
@ -181,7 +180,8 @@ class AutorForm(ModelForm):
autor_select = Row(to_column(('tipo', 3)), autor_select = Row(to_column(('tipo', 3)),
Div(to_column(('nome', 5)), Div(to_column(('nome', 5)),
to_column(('cargo', 4)), css_class="div_nome_cargo"), to_column(('cargo', 4)),
css_class="div_nome_cargo"),
to_column((autor_related, 9)), to_column((autor_related, 9)),
to_column((Div( to_column((Div(
Field('autor_related'), Field('autor_related'),

3
sapl/base/templatetags/menus.py

@ -1,11 +1,10 @@
import yaml
from django import template from django import template
from django.core.urlresolvers import reverse from django.core.urlresolvers import reverse
from django.utils.translation import ugettext_lazy as _ from django.utils.translation import ugettext_lazy as _
import yaml
from sapl.utils import sapl_logger from sapl.utils import sapl_logger
register = template.Library() register = template.Library()

2
sapl/base/urls.py

@ -3,7 +3,7 @@ from django.contrib.auth import views
from django.contrib.auth.decorators import permission_required from django.contrib.auth.decorators import permission_required
from django.views.generic.base import TemplateView from django.views.generic.base import TemplateView
from sapl.base.views import AutorCrud, TipoAutorCrud, ConfirmarEmailView from sapl.base.views import AutorCrud, ConfirmarEmailView, TipoAutorCrud
from .apps import AppConfig from .apps import AppConfig
from .forms import LoginForm from .forms import LoginForm

4
sapl/base/views.py

@ -9,12 +9,12 @@ from django.core.urlresolvers import reverse
from django.db.models import Count, Q from django.db.models import Count, Q
from django.http import HttpResponseRedirect from django.http import HttpResponseRedirect
from django.utils.encoding import force_bytes from django.utils.encoding import force_bytes
from django.utils.http import urlsafe_base64_encode, urlsafe_base64_decode from django.utils.http import urlsafe_base64_decode, urlsafe_base64_encode
from django.utils.translation import ugettext_lazy as _ from django.utils.translation import ugettext_lazy as _
from django.views.generic.base import TemplateView from django.views.generic.base import TemplateView
from django_filters.views import FilterView from django_filters.views import FilterView
from sapl.base.forms import AutorForm, TipoAutorForm, AutorFormForAdmin from sapl.base.forms import AutorForm, AutorFormForAdmin, TipoAutorForm
from sapl.base.models import Autor, TipoAutor from sapl.base.models import Autor, TipoAutor
from sapl.crud.base import CrudAux from sapl.crud.base import CrudAux
from sapl.materia.models import MateriaLegislativa, TipoMateriaLegislativa from sapl.materia.models import MateriaLegislativa, TipoMateriaLegislativa

2
sapl/comissoes/views.py

@ -3,7 +3,7 @@ from django.core.urlresolvers import reverse
from django.db.models import F from django.db.models import F
from django.views.generic import ListView from django.views.generic import ListView
from sapl.crud.base import Crud, CrudAux, MasterDetailCrud, RP_DETAIL, RP_LIST from sapl.crud.base import RP_DETAIL, RP_LIST, Crud, CrudAux, MasterDetailCrud
from sapl.materia.models import MateriaLegislativa, Tramitacao from sapl.materia.models import MateriaLegislativa, Tramitacao
from .models import (CargoComissao, Comissao, Composicao, Participacao, from .models import (CargoComissao, Comissao, Composicao, Participacao,

7
sapl/compilacao/views.py

@ -1,7 +1,7 @@
from collections import OrderedDict
from datetime import datetime, timedelta
import logging import logging
import sys import sys
from collections import OrderedDict
from datetime import datetime, timedelta
from braces.views import FormMessagesMixin from braces.views import FormMessagesMixin
from django import forms from django import forms
@ -20,8 +20,8 @@ from django.shortcuts import get_object_or_404, redirect
from django.utils.dateparse import parse_date from django.utils.dateparse import parse_date
from django.utils.decorators import method_decorator from django.utils.decorators import method_decorator
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.base import TemplateView from django.views.generic.base import TemplateView
from django.views.generic.detail import DetailView from django.views.generic.detail import DetailView
from django.views.generic.edit import (CreateView, DeleteView, FormView, from django.views.generic.edit import (CreateView, DeleteView, FormView,
@ -49,7 +49,6 @@ from sapl.compilacao.utils import (DISPOSITIVO_SELECT_RELATED,
from sapl.crud.base import Crud, CrudListView, make_pagination from sapl.crud.base import Crud, CrudListView, make_pagination
from sapl.settings import BASE_DIR from sapl.settings import BASE_DIR
TipoNotaCrud = Crud.build(TipoNota, 'tipo_nota') TipoNotaCrud = Crud.build(TipoNota, 'tipo_nota')
TipoVideCrud = Crud.build(TipoVide, 'tipo_vide') TipoVideCrud = Crud.build(TipoVide, 'tipo_vide')
TipoPublicacaoCrud = Crud.build(TipoPublicacao, 'tipo_publicacao') TipoPublicacaoCrud = Crud.build(TipoPublicacao, 'tipo_publicacao')

5
sapl/crud/base.py

@ -14,8 +14,8 @@ from django.db.models.fields.related import ForeignKey
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
@ -25,7 +25,6 @@ from sapl.crispy_layout_mixin import CrispyLayoutFormMixin, get_field_display
from sapl.settings import BASE_DIR from sapl.settings import BASE_DIR
from sapl.utils import normalize from sapl.utils import normalize
logger = logging.getLogger(BASE_DIR.name) logger = logging.getLogger(BASE_DIR.name)
ACTION_LIST, ACTION_CREATE, ACTION_DETAIL, ACTION_UPDATE, ACTION_DELETE = \ ACTION_LIST, ACTION_CREATE, ACTION_DETAIL, ACTION_UPDATE, ACTION_DELETE = \
@ -1287,7 +1286,7 @@ class MasterDetailCrud(Crud):
if hasattr(obj, 'parent_field'): if hasattr(obj, 'parent_field'):
parent_field = obj.parent_field.split('__') parent_field = obj.parent_field.split('__')
if not obj.is_m2m or len(parent_field) > 1: if not obj.is_m2m or len(parent_field) > 1:
field = self.model._meta.get_field(parent_field[0]) # field = self.model._meta.get_field(parent_field[0])
if isinstance(getattr( if isinstance(getattr(
self.object, parent_field[0]), models.Model): self.object, parent_field[0]), models.Model):

10
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
@ -8,7 +9,6 @@ from django.db import models
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.base.models import Autor from sapl.base.models import Autor
from sapl.comissoes.models import Comissao from sapl.comissoes.models import Comissao
@ -20,10 +20,10 @@ from sapl.settings import MAX_DOC_UPLOAD_SIZE
from sapl.utils import (RANGE_ANOS, RangeWidgetOverride, autor_label, from sapl.utils import (RANGE_ANOS, RangeWidgetOverride, autor_label,
autor_modal) autor_modal)
from .models import (AcompanhamentoMateria, Anexada, Autoria, from .models import (AcompanhamentoMateria, Anexada, Autoria, DespachoInicial,
DespachoInicial, DocumentoAcessorio, MateriaLegislativa, DocumentoAcessorio, MateriaLegislativa, Numeracao,
Numeracao, Proposicao, Relatoria, TipoMateriaLegislativa, Proposicao, Relatoria, TipoMateriaLegislativa, Tramitacao,
Tramitacao, UnidadeTramitacao) UnidadeTramitacao)
def ANO_CHOICES(): def ANO_CHOICES():

2
sapl/materia/models.py

@ -7,10 +7,8 @@ from sapl.base.models import Autor
from sapl.comissoes.models import Comissao from sapl.comissoes.models import Comissao
from sapl.parlamentares.models import Parlamentar from sapl.parlamentares.models import Parlamentar
from sapl.utils import (RANGE_ANOS, YES_NO_CHOICES, from sapl.utils import (RANGE_ANOS, YES_NO_CHOICES,
get_settings_auth_user_model,
restringe_tipos_de_arquivo_txt) restringe_tipos_de_arquivo_txt)
EM_TRAMITACAO = [(1, 'Sim'), EM_TRAMITACAO = [(1, 'Sim'),
(0, 'Não')] (0, 'Não')]

4
sapl/materia/tests/test_materia.py

@ -1,10 +1,10 @@
import pytest
from django.contrib.auth import get_user_model from django.contrib.auth import get_user_model
from django.core.files.uploadedfile import SimpleUploadedFile from django.core.files.uploadedfile import SimpleUploadedFile
from django.core.urlresolvers import reverse from django.core.urlresolvers import reverse
from model_mommy import mommy from model_mommy import mommy
import pytest
from sapl.base.models import TipoAutor, Autor from sapl.base.models import Autor, TipoAutor
from sapl.comissoes.models import Comissao, TipoComissao from sapl.comissoes.models import Comissao, TipoComissao
from sapl.materia.models import (Anexada, Autoria, DespachoInicial, from sapl.materia.models import (Anexada, Autoria, DespachoInicial,
DocumentoAcessorio, MateriaLegislativa, DocumentoAcessorio, MateriaLegislativa,

5
sapl/materia/urls.py

@ -3,9 +3,8 @@ from django.conf.urls import include, url
from sapl.materia.views import (AcompanhamentoConfirmarView, from sapl.materia.views import (AcompanhamentoConfirmarView,
AcompanhamentoExcluirView, AcompanhamentoExcluirView,
AcompanhamentoMateriaView, AnexadaCrud, AcompanhamentoMateriaView, AnexadaCrud,
AutoriaCrud, AutoriaCrud, ConfirmarProposicao,
ConfirmarProposicao, DespachoInicialCrud, DespachoInicialCrud, DocumentoAcessorioCrud,
DocumentoAcessorioCrud,
DocumentoAcessorioEmLoteView, DocumentoAcessorioEmLoteView,
LegislacaoCitadaCrud, MateriaLegislativaCrud, LegislacaoCitadaCrud, MateriaLegislativaCrud,
MateriaLegislativaPesquisaView, MateriaTaView, MateriaLegislativaPesquisaView, MateriaTaView,

7
sapl/materia/views.py

@ -5,7 +5,6 @@ from string import ascii_letters, digits
from crispy_forms.helper import FormHelper from crispy_forms.helper import FormHelper
from crispy_forms.layout import HTML from crispy_forms.layout import HTML
from django.contrib import messages from django.contrib import messages
from django.contrib.auth import get_user_model
from django.contrib.auth.mixins import PermissionRequiredMixin from django.contrib.auth.mixins import PermissionRequiredMixin
from django.core.exceptions import MultipleObjectsReturned, ObjectDoesNotExist from django.core.exceptions import MultipleObjectsReturned, ObjectDoesNotExist
from django.core.mail import send_mail from django.core.mail import send_mail
@ -15,7 +14,6 @@ from django.http import JsonResponse
from django.http.response import HttpResponseRedirect from django.http.response import HttpResponseRedirect
from django.shortcuts import redirect from django.shortcuts import redirect
from django.template import Context, loader from django.template import Context, loader
from django.utils.http import urlsafe_base64_decode
from django.utils.translation import ugettext_lazy as _ from django.utils.translation import ugettext_lazy as _
from django.views.generic import CreateView, ListView, TemplateView, UpdateView from django.views.generic import CreateView, ListView, TemplateView, UpdateView
from django.views.generic.base import RedirectView from django.views.generic.base import RedirectView
@ -33,10 +31,9 @@ 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,
autor_modal, gerar_hash_arquivo, get_base_url, autor_modal, gerar_hash_arquivo, get_base_url,
montar_row_autor, permission_required_for_app,
permissoes_autor, permissoes_materia, permissoes_autor, permissoes_materia,
permissoes_protocoloadm, permission_required_for_app, permissoes_protocoloadm)
montar_row_autor)
from .forms import (AcessorioEmLoteFilterSet, AcompanhamentoMateriaForm, from .forms import (AcessorioEmLoteFilterSet, AcompanhamentoMateriaForm,
ConfirmarProposicaoForm, DocumentoAcessorioForm, ConfirmarProposicaoForm, DocumentoAcessorioForm,

5
sapl/parlamentares/views.py

@ -12,9 +12,8 @@ from sapl.crud.base import (RP_CHANGE, RP_DETAIL, RP_LIST, Crud, CrudAux,
from sapl.materia.models import Proposicao, Relatoria from sapl.materia.models import Proposicao, Relatoria
from sapl.parlamentares.apps import AppConfig from sapl.parlamentares.apps import AppConfig
from .forms import (FiliacaoForm, LegislaturaCreateForm, from .forms import (FiliacaoForm, LegislaturaCreateForm, LegislaturaUpdateForm,
LegislaturaUpdateForm, ParlamentarCreateForm, ParlamentarCreateForm, ParlamentarForm)
ParlamentarForm)
from .models import (CargoMesa, Coligacao, ComposicaoColigacao, ComposicaoMesa, from .models import (CargoMesa, Coligacao, ComposicaoColigacao, ComposicaoMesa,
Dependente, Filiacao, Frente, Legislatura, Mandato, Dependente, Filiacao, Frente, Legislatura, Mandato,
NivelInstrucao, Parlamentar, Partido, SessaoLegislativa, NivelInstrucao, Parlamentar, Partido, SessaoLegislativa,

3
sapl/protocoloadm/forms.py

@ -1,5 +1,6 @@
from datetime import datetime from datetime import datetime
import django_filters
from crispy_forms.bootstrap import InlineRadios from crispy_forms.bootstrap import InlineRadios
from crispy_forms.helper import FormHelper from crispy_forms.helper import FormHelper
from crispy_forms.layout import HTML, Button, Fieldset, Layout, Submit from crispy_forms.layout import HTML, Button, Fieldset, Layout, Submit
@ -8,7 +9,6 @@ from django.core.exceptions import ObjectDoesNotExist, ValidationError
from django.db import models from django.db import models
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.base.models import Autor from sapl.base.models import Autor
from sapl.crispy_layout_mixin import form_actions, to_row from sapl.crispy_layout_mixin import form_actions, to_row
@ -20,7 +20,6 @@ from .models import (DocumentoAcessorioAdministrativo, DocumentoAdministrativo,
Protocolo, TipoDocumentoAdministrativo, Protocolo, TipoDocumentoAdministrativo,
TramitacaoAdministrativo) TramitacaoAdministrativo)
TIPOS_PROTOCOLO = [('0', 'Enviado'), ('1', 'Recebido'), ('', 'Ambos')] TIPOS_PROTOCOLO = [('0', 'Enviado'), ('1', 'Recebido'), ('', 'Ambos')]
NATUREZA_PROCESSO = [('', 'Ambos'), NATUREZA_PROCESSO = [('', 'Ambos'),

3
sapl/protocoloadm/models.py

@ -5,8 +5,7 @@ from django.utils.translation import ugettext_lazy as _
from model_utils import Choices from model_utils import Choices
from sapl.base.models import Autor from sapl.base.models import Autor
from sapl.materia.models import (TipoMateriaLegislativa, from sapl.materia.models import TipoMateriaLegislativa, UnidadeTramitacao
UnidadeTramitacao)
from sapl.utils import RANGE_ANOS, YES_NO_CHOICES from sapl.utils import RANGE_ANOS, YES_NO_CHOICES

14
sapl/protocoloadm/views.py

@ -1,13 +1,11 @@
from datetime import date, datetime from datetime import date, datetime
import json
from braces.views import FormValidMessageMixin from braces.views import FormValidMessageMixin
from django.contrib import messages from django.contrib import messages
from django.contrib.auth.mixins import PermissionRequiredMixin from django.contrib.auth.mixins import PermissionRequiredMixin
from django.core.exceptions import ObjectDoesNotExist
from django.core.urlresolvers import reverse from django.core.urlresolvers import reverse
from django.db.models import Max, Q from django.db.models import Max
from django.http import HttpResponse, HttpResponseRedirect from django.http import HttpResponseRedirect
from django.shortcuts import redirect 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 CreateView, DetailView, FormView, ListView from django.views.generic import CreateView, DetailView, FormView, ListView
@ -15,7 +13,7 @@ from django.views.generic.base import TemplateView
from django_filters.views import FilterView from django_filters.views import FilterView
from sapl.base.apps import AppConfig as AppsAppConfig from sapl.base.apps import AppConfig as AppsAppConfig
from sapl.base.models import AppConfig, Autor from sapl.base.models import AppConfig
from sapl.crud.base import Crud, CrudAux, MasterDetailCrud, make_pagination from sapl.crud.base import Crud, CrudAux, MasterDetailCrud, make_pagination
from sapl.materia.models import TipoMateriaLegislativa from sapl.materia.models import TipoMateriaLegislativa
from sapl.utils import (create_barcode, get_client_ip, permissoes_adm, from sapl.utils import (create_barcode, get_client_ip, permissoes_adm,
@ -26,12 +24,10 @@ from .forms import (AnularProcoloAdmForm, DocumentoAcessorioAdministrativoForm,
DocumentoAdministrativoForm, ProtocoloDocumentForm, DocumentoAdministrativoForm, ProtocoloDocumentForm,
ProtocoloFilterSet, ProtocoloMateriaForm, ProtocoloFilterSet, ProtocoloMateriaForm,
TramitacaoAdmEditForm, TramitacaoAdmForm) TramitacaoAdmEditForm, TramitacaoAdmForm)
from .models import (DocumentoAcessorioAdministrativo, from .models import (DocumentoAcessorioAdministrativo, DocumentoAdministrativo,
DocumentoAdministrativo, Protocolo, Protocolo, StatusTramitacaoAdministrativo,
StatusTramitacaoAdministrativo,
TipoDocumentoAdministrativo, TramitacaoAdministrativo) TipoDocumentoAdministrativo, TramitacaoAdministrativo)
TipoDocumentoAdministrativoCrud = CrudAux.build( TipoDocumentoAdministrativoCrud = CrudAux.build(
TipoDocumentoAdministrativo, '') TipoDocumentoAdministrativo, '')

2
sapl/relatorios/views.py

@ -4,7 +4,7 @@ from bs4 import BeautifulSoup
from django.http import Http404, HttpResponse from django.http import Http404, HttpResponse
from django.utils.translation import ugettext_lazy as _ from django.utils.translation import ugettext_lazy as _
from sapl.base.models import CasaLegislativa, Autor from sapl.base.models import Autor, CasaLegislativa
from sapl.comissoes.models import Comissao from sapl.comissoes.models import Comissao
from sapl.materia.models import (Autoria, MateriaLegislativa, Numeracao, from sapl.materia.models import (Autoria, MateriaLegislativa, Numeracao,
Tramitacao, UnidadeTramitacao) Tramitacao, UnidadeTramitacao)

4
sapl/sessao/models.py

@ -6,8 +6,8 @@ from sapl.base.models import Autor
from sapl.materia.models import MateriaLegislativa from sapl.materia.models import MateriaLegislativa
from sapl.parlamentares.models import (CargoMesa, Legislatura, Parlamentar, from sapl.parlamentares.models import (CargoMesa, Legislatura, Parlamentar,
Partido, SessaoLegislativa) Partido, SessaoLegislativa)
from sapl.utils import YES_NO_CHOICES, restringe_tipos_de_arquivo_txt,\ from sapl.utils import (YES_NO_CHOICES, SaplGenericRelation,
SaplGenericRelation restringe_tipos_de_arquivo_txt)
class CargoBancada(models.Model): class CargoBancada(models.Model):

1
sapl/sessao/views.py

@ -45,7 +45,6 @@ from .models import (Bancada, Bloco, CargoBancada, CargoMesa,
SessaoPlenariaPresenca, TipoExpediente, SessaoPlenariaPresenca, TipoExpediente,
TipoResultadoVotacao, TipoSessaoPlenaria, VotoParlamentar) TipoResultadoVotacao, TipoSessaoPlenaria, VotoParlamentar)
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, '')

3
sapl/settings.py

@ -23,7 +23,6 @@ from unipath import Path
from .temp_suppress_crispy_form_warnings import \ from .temp_suppress_crispy_form_warnings import \
SUPRESS_CRISPY_FORM_WARNINGS_LOGGING SUPRESS_CRISPY_FORM_WARNINGS_LOGGING
BASE_DIR = Path(__file__).ancestor(1) BASE_DIR = Path(__file__).ancestor(1)
PROJECT_DIR = Path(__file__).ancestor(2) PROJECT_DIR = Path(__file__).ancestor(2)
@ -98,7 +97,7 @@ MIDDLEWARE_CLASSES = (
REST_FRAMEWORK = { REST_FRAMEWORK = {
"DEFAULT_RENDERER_CLASSES": ( "DEFAULT_RENDERER_CLASSES": (
"rest_framework.renderers.JSONRenderer", "rest_framework.renderers.JSONRenderer",
#"rest_framework.renderers.BrowsableAPIRenderer", # "rest_framework.renderers.BrowsableAPIRenderer",
), ),
"DEFAULT_PARSER_CLASSES": ( "DEFAULT_PARSER_CLASSES": (
"rest_framework.parsers.JSONParser", "rest_framework.parsers.JSONParser",

7
sapl/test_urls.py

@ -1,22 +1,19 @@
import pytest
from django.apps import apps from django.apps import apps
from django.contrib.auth import get_user_model from django.contrib.auth import get_user_model
from django.contrib.auth.management import _get_all_permissions from django.contrib.auth.management import _get_all_permissions
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.db import transaction from django.db import transaction
from django.utils.translation import string_concat
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 sapl.crud.base import PermissionRequiredForAppCrudMixin from sapl.crud.base import PermissionRequiredForAppCrudMixin
from sapl.materia.views import recuperar_materia
from scripts.inicializa_grupos_autorizacoes import cria_grupos_permissoes from scripts.inicializa_grupos_autorizacoes import cria_grupos_permissoes
from scripts.lista_urls import lista_urls from scripts.lista_urls import lista_urls
from .settings import SAPL_APPS from .settings import SAPL_APPS
pytestmark = pytest.mark.django_db pytestmark = pytest.mark.django_db
sapl_appconfs = [apps.get_app_config(n[5:]) for n in SAPL_APPS] sapl_appconfs = [apps.get_app_config(n[5:]) for n in SAPL_APPS]

16
sapl/utils.py

@ -1,9 +1,10 @@
import hashlib
import logging
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 logging
import magic
from crispy_forms.helper import FormHelper from crispy_forms.helper import FormHelper
from crispy_forms.layout import HTML, Button from crispy_forms.layout import HTML, Button
from django import forms from django import forms
@ -17,11 +18,10 @@ from django.contrib.contenttypes.models import ContentType
from django.core.exceptions import PermissionDenied, ValidationError 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
from sapl.crispy_layout_mixin import SaplFormLayout, form_actions, to_row from sapl.crispy_layout_mixin import SaplFormLayout, form_actions, to_row
import magic
from sapl.settings import BASE_DIR from sapl.settings import BASE_DIR
sapl_logger = logging.getLogger(BASE_DIR.name) sapl_logger = logging.getLogger(BASE_DIR.name)
@ -121,8 +121,10 @@ class SaplGenericRelation(GenericRelation):
) )
[ref_1]: https://docs.djangoproject.com/el/1.10/topics/db/queries/#field-lookups [ref_1]: https://docs.djangoproject.com/el/1.10/topics/db/queries/
[ref_2]: https://github.com/interlegis/sapl/blob/master/sapl/parlamentares/models.py #field-lookups
[ref_2]: https://github.com/interlegis/sapl/blob/master/sapl/
parlamentares/models.py
""" """
def __init__(self, to, fields_search=(), **kwargs): def __init__(self, to, fields_search=(), **kwargs):
@ -136,7 +138,7 @@ class SaplGenericRelation(GenericRelation):
for field in fields_search: for field in fields_search:
# descomente para ver todas os campos que são elementos de busca # descomente para ver todas os campos que são elementos de busca
#print(kwargs['related_query_name'], field) # print(kwargs['related_query_name'], field)
assert isinstance(field, (tuple, list)), _( assert isinstance(field, (tuple, list)), _(
'fields_search deve ser um array de tuplas ou listas.') 'fields_search deve ser um array de tuplas ou listas.')

1
scripts/inicializa_grupos_autorizacoes.py

@ -10,7 +10,6 @@ if True:
from django.contrib.auth import get_user_model from django.contrib.auth import get_user_model
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 sapl.base.models import Autor
class InicializaGruposAutorizacoes(): class InicializaGruposAutorizacoes():

Loading…
Cancel
Save