Browse Source

Fix qa

pull/781/head
Eduardo Edson Batista Cordeiro Alves 8 years ago
parent
commit
788dad162b
  1. 2
      sapl/api/forms.py
  2. 1
      sapl/api/serializers.py
  3. 6
      sapl/api/urls.py
  4. 9
      sapl/api/views.py
  5. 2
      sapl/base/apps.py
  6. 15
      sapl/base/forms.py
  7. 10
      sapl/base/models.py
  8. 3
      sapl/base/templatetags/menus.py
  9. 2
      sapl/base/views.py
  10. 2
      sapl/crispy_layout_mixin.py
  11. 3
      sapl/crud/base.py
  12. 57
      sapl/materia/forms.py
  13. 13
      sapl/materia/models.py
  14. 2
      sapl/materia/tests/test_materia.py
  15. 35
      sapl/materia/views.py
  16. 2
      sapl/norma/models.py
  17. 6
      sapl/protocoloadm/models.py
  18. 2
      sapl/protocoloadm/tests/test_protocoloadm.py
  19. 9
      sapl/protocoloadm/views.py
  20. 2
      sapl/relatorios/views.py
  21. 21
      sapl/rules/apps.py
  22. 17
      sapl/rules/map_rules.py
  23. 3
      sapl/rules/tests/test_rules.py
  24. 2
      sapl/sessao/views.py
  25. 7
      sapl/test_urls.py
  26. 1
      sapl/urls.py
  27. 23
      sapl/utils.py

2
sapl/api/forms.py

@ -1,6 +1,7 @@
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.models import Autor, TipoAutor from sapl.base.models import Autor, TipoAutor
from sapl.utils import generic_relations_for_model from sapl.utils import generic_relations_for_model
@ -21,7 +22,6 @@ class SaplGenericRelationSearchFilterSet(FilterSet):
order_by = [] order_by = []
for gr in generic_relations_for_model(self._meta.model): for gr in generic_relations_for_model(self._meta.model):
model = gr[0]
sgr = gr[1] sgr = gr[1]
for item in sgr: for item in sgr:
if item.related_model != self._meta.model: if item.related_model != self._meta.model:

1
sapl/api/serializers.py

@ -1,4 +1,5 @@
from rest_framework import serializers from rest_framework import serializers
from sapl.base.models import Autor from sapl.base.models import Autor
from sapl.materia.models import MateriaLegislativa from sapl.materia.models import MateriaLegislativa

6
sapl/api/urls.py

@ -1,9 +1,9 @@
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 rest_framework.routers import DefaultRouter from rest_framework.routers import DefaultRouter
from sapl.api.views import MateriaLegislativaViewSet, AutorListView,\ from sapl.api.views import (AutorListView, MateriaLegislativaViewSet,
ModelChoiceView ModelChoiceView)
from .apps import AppConfig from .apps import AppConfig

9
sapl/api/views.py

@ -5,13 +5,14 @@ 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.mixins import ListModelMixin, RetrieveModelMixin from rest_framework.mixins import ListModelMixin, RetrieveModelMixin
from rest_framework.permissions import IsAuthenticated, AllowAny from rest_framework.permissions import IsAuthenticated
from rest_framework.viewsets import GenericViewSet from rest_framework.viewsets import GenericViewSet
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, ModelChoiceSerializer, MateriaLegislativaSerializer ChoiceSerializer,
MateriaLegislativaSerializer,
ModelChoiceSerializer)
from sapl.base.models import Autor, TipoAutor from sapl.base.models import Autor, TipoAutor
from sapl.materia.models import MateriaLegislativa from sapl.materia.models import MateriaLegislativa
from sapl.utils import SaplGenericRelation, sapl_logger from sapl.utils import SaplGenericRelation, sapl_logger

2
sapl/base/apps.py

@ -1,6 +1,6 @@
from django.utils.translation import ugettext_lazy as _
import django import django
from django.utils.translation import ugettext_lazy as _
class AppConfig(django.apps.AppConfig): class AppConfig(django.apps.AppConfig):

15
sapl/base/forms.py

@ -1,22 +1,17 @@
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
from django.contrib.auth.forms import AuthenticationForm from django.contrib.auth.forms import AuthenticationForm
from django.contrib.auth.models import Group from django.contrib.auth.models import Group
from django.contrib.auth.password_validation import validate_password from django.contrib.auth.password_validation import validate_password
from django.contrib.contenttypes.fields import GenericRel
from django.contrib.contenttypes.models import ContentType 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
import django_filters
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.utils.translation import string_concat
@ -26,11 +21,9 @@ from sapl.crispy_layout_mixin import (SaplFormLayout, form_actions, to_column,
from sapl.materia.models import MateriaLegislativa 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, ChoiceWithoutValidationField,
RangeWidgetOverride, autor_label, autor_modal, ImageThumbnailFileInput, RangeWidgetOverride,
autor_label, autor_modal, models_with_gr_for_model)
SaplGenericRelation, models_with_gr_for_model,
ChoiceWithoutValidationField)
from .models import AppConfig, CasaLegislativa from .models import AppConfig, CasaLegislativa

10
sapl/base/models.py

@ -1,18 +1,10 @@
from builtins import LookupError
from django.apps import apps
from django.contrib.auth.management import _get_all_permissions
from django.contrib.contenttypes.fields import GenericForeignKey from django.contrib.contenttypes.fields import GenericForeignKey
from django.contrib.contenttypes.models import ContentType from django.contrib.contenttypes.models import ContentType
from django.core import exceptions from django.db import models
from django.db import models, router
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 sapl.utils import UF, YES_NO_CHOICES, get_settings_auth_user_model from sapl.utils import UF, YES_NO_CHOICES, get_settings_auth_user_model
TIPO_DOCUMENTO_ADMINISTRATIVO = (('O', _('Ostensivo')), TIPO_DOCUMENTO_ADMINISTRATIVO = (('O', _('Ostensivo')),
('R', _('Restritivo'))) ('R', _('Restritivo')))

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/views.py

@ -13,8 +13,8 @@ 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/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

@ -16,8 +16,8 @@ from django.http.response import Http404
from django.shortcuts import redirect from django.shortcuts import redirect
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
@ -27,7 +27,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 = \

57
sapl/materia/forms.py

@ -1,12 +1,13 @@
from datetime import datetime, date
import os import os
from datetime import date, datetime
from crispy_forms.bootstrap import Alert, InlineCheckboxes, FormActions,\ import django_filters
InlineRadios from crispy_forms.bootstrap import (Alert, FormActions, InlineCheckboxes,
InlineRadios)
from crispy_forms.helper import FormHelper from crispy_forms.helper import FormHelper
from crispy_forms.layout import HTML, Button, Column, Fieldset, Layout, Row,\ from crispy_forms.layout import (HTML, Button, Column, Field, Fieldset, Layout,
Field, Submit Submit)
from django import forms from django import forms
from django.contrib.contenttypes.models import ContentType from django.contrib.contenttypes.models import ContentType
from django.core.exceptions import ObjectDoesNotExist, ValidationError from django.core.exceptions import ObjectDoesNotExist, ValidationError
@ -17,22 +18,21 @@ from django.db.models import Max
from django.forms import ModelForm, widgets from django.forms import ModelForm, widgets
from django.forms.forms import Form from django.forms.forms import Form
from django.utils.translation import ugettext_lazy as _ from django.utils.translation import ugettext_lazy as _
import django_filters
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.crispy_layout_mixin import form_actions, to_row, to_column,\ from sapl.crispy_layout_mixin import (SaplFormLayout, form_actions, to_column,
SaplFormLayout to_row)
from sapl.materia.models import TipoProposicao, RegimeTramitacao, TipoDocumento from sapl.materia.models import RegimeTramitacao, 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.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, RangeWidgetOverride, autor_label, from sapl.utils import (RANGE_ANOS, YES_NO_CHOICES,
autor_modal, models_with_gr_for_model, ChoiceWithoutValidationField, RangeWidgetOverride,
ChoiceWithoutValidationField, YES_NO_CHOICES) autor_label, autor_modal, models_with_gr_for_model)
import sapl
from .models import (AcompanhamentoMateria, Anexada, Autoria, DespachoInicial, from .models import (AcompanhamentoMateria, Anexada, Autoria, DespachoInicial,
DocumentoAcessorio, MateriaLegislativa, Numeracao, DocumentoAcessorio, MateriaLegislativa, Numeracao,
@ -829,7 +829,8 @@ class TipoProposicaoForm(ModelForm):
content_type = cd['content_type'] content_type = cd['content_type']
if 'tipo_conteudo_related' not in cd or not cd['tipo_conteudo_related']: if 'tipo_conteudo_related' not in cd or not cd[
'tipo_conteudo_related']:
raise ValidationError( raise ValidationError(
_('Seleção de Tipo não definida')) _('Seleção de Tipo não definida'))
@ -951,11 +952,14 @@ class ProposicaoForm(forms.ModelForm):
if self.instance.materia_de_vinculo: if self.instance.materia_de_vinculo:
self.fields[ self.fields[
'tipo_materia'].initial = self.instance.materia_de_vinculo.tipo 'tipo_materia'
].initial = self.instance.materia_de_vinculo.tipo
self.fields[ self.fields[
'numero_materia'].initial = self.instance.materia_de_vinculo.numero 'numero_materia'
].initial = self.instance.materia_de_vinculo.numero
self.fields[ self.fields[
'ano_materia'].initial = self.instance.materia_de_vinculo.ano 'ano_materia'
].initial = self.instance.materia_de_vinculo.ano
def clean_texto_original(self): def clean_texto_original(self):
texto_original = self.cleaned_data.get('texto_original', False) texto_original = self.cleaned_data.get('texto_original', False)
@ -1128,11 +1132,14 @@ class ConfirmarProposicaoForm(ProposicaoForm):
if self.instance.materia_de_vinculo: if self.instance.materia_de_vinculo:
self.fields[ self.fields[
'tipo_materia'].initial = self.instance.materia_de_vinculo.tipo 'tipo_materia'
].initial = self.instance.materia_de_vinculo.tipo
self.fields[ self.fields[
'numero_materia'].initial = self.instance.materia_de_vinculo.numero 'numero_materia'
].initial = self.instance.materia_de_vinculo.numero
self.fields[ self.fields[
'ano_materia'].initial = self.instance.materia_de_vinculo.ano 'ano_materia'
].initial = self.instance.materia_de_vinculo.ano
if self.proposicao_incorporacao_obrigatoria == 'C': if self.proposicao_incorporacao_obrigatoria == 'C':
self.fields['gerar_protocolo'].initial = True self.fields['gerar_protocolo'].initial = True
@ -1148,8 +1155,8 @@ class ConfirmarProposicaoForm(ProposicaoForm):
raise ValidationError( raise ValidationError(
_('Regimente de Tramitação deve ser informado.')) _('Regimente de Tramitação deve ser informado.'))
elif self.instance.tipo.content_type.model_class() == TipoDocumento\ elif self.instance.tipo.content_type.model_class(
and not cd['materia_de_vinculo']: ) == TipoDocumento and not cd['materia_de_vinculo']:
raise ValidationError( raise ValidationError(
_('Documentos não podem ser incorporados sem definir ' _('Documentos não podem ser incorporados sem definir '
@ -1216,7 +1223,8 @@ class ConfirmarProposicaoForm(ProposicaoForm):
proposicao = self.instance proposicao = self.instance
conteudo_gerado = None conteudo_gerado = None
if self.instance.tipo.content_type.model_class() == TipoMateriaLegislativa: if self.instance.tipo.content_type.model_class(
) == TipoMateriaLegislativa:
numero__max = MateriaLegislativa.objects.filter( numero__max = MateriaLegislativa.objects.filter(
tipo=proposicao.tipo.tipo_conteudo_related, tipo=proposicao.tipo.tipo_conteudo_related,
ano=datetime.now().year).aggregate(Max('numero')) ano=datetime.now().year).aggregate(Max('numero'))
@ -1349,7 +1357,8 @@ class ConfirmarProposicaoForm(ProposicaoForm):
protocolo.numero_paginas = cd['numero_de_paginas'] protocolo.numero_paginas = cd['numero_de_paginas']
protocolo.anulado = False protocolo.anulado = False
if self.instance.tipo.content_type.model_class() == TipoMateriaLegislativa: if self.instance.tipo.content_type.model_class(
) == TipoMateriaLegislativa:
protocolo.tipo_materia = proposicao.tipo.tipo_conteudo_related protocolo.tipo_materia = proposicao.tipo.tipo_conteudo_related
elif self.instance.tipo.content_type.model_class() == TipoDocumento: elif self.instance.tipo.content_type.model_class() == TipoDocumento:
protocolo.tipo_documento = proposicao.tipo.tipo_conteudo_related protocolo.tipo_documento = proposicao.tipo.tipo_conteudo_related

13
sapl/materia/models.py

@ -1,9 +1,5 @@
import datetime
import re
from django.contrib.auth.models import Group from django.contrib.auth.models import Group
from django.contrib.contenttypes.fields import GenericForeignKey,\ from django.contrib.contenttypes.fields import GenericRelation
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.db.models.deletion import PROTECT
@ -14,10 +10,9 @@ from sapl.base.models import Autor
from sapl.comissoes.models import Comissao from sapl.comissoes.models import Comissao
from sapl.compilacao.models import TextoArticulado from sapl.compilacao.models import TextoArticulado
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, SaplGenericForeignKey,
restringe_tipos_de_arquivo_txt, SaplGenericRelation, SaplGenericRelation, restringe_tipos_de_arquivo_txt,
SaplGenericForeignKey, texto_upload_path) texto_upload_path)
EM_TRAMITACAO = [(1, 'Sim'), EM_TRAMITACAO = [(1, 'Sim'),
(0, 'Não')] (0, 'Não')]

2
sapl/materia/tests/test_materia.py

@ -1,9 +1,9 @@
import pytest
from django.contrib.auth import get_user_model from django.contrib.auth import get_user_model
from django.contrib.contenttypes.models import ContentType from django.contrib.contenttypes.models import ContentType
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 Autor, TipoAutor from sapl.base.models import Autor, TipoAutor
from sapl.comissoes.models import Comissao, TipoComissao from sapl.comissoes.models import Comissao, TipoComissao

35
sapl/materia/views.py

@ -6,49 +6,43 @@ 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.mixins import PermissionRequiredMixin from django.contrib.auth.mixins import PermissionRequiredMixin
from django.core.exceptions import MultipleObjectsReturned, ObjectDoesNotExist,\ from django.core.exceptions import ObjectDoesNotExist
PermissionDenied
from django.core.mail import send_mail from django.core.mail import send_mail
from django.core.urlresolvers import reverse from django.core.urlresolvers import reverse
from django.db.models import Q
from django.http import JsonResponse from django.http import JsonResponse
from django.http.response import HttpResponseRedirect, Http404 from django.http.response import Http404, 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 import dateformat, formats from django.utils import formats
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
from django.views.generic.edit import FormView from django.views.generic.edit import FormView
from django_filters.views import FilterView from django_filters.views import FilterView
from sapl.base.models import Autor, CasaLegislativa, TipoAutor import sapl
from sapl.base.models import Autor, CasaLegislativa
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
from sapl.crud.base import (ACTION_CREATE, ACTION_DELETE, ACTION_DETAIL, from sapl.crud.base import (ACTION_CREATE, ACTION_DELETE, ACTION_DETAIL,
ACTION_LIST, ACTION_UPDATE, RP_DETAIL, RP_LIST, ACTION_LIST, ACTION_UPDATE, RP_DETAIL, RP_LIST,
Crud, CrudAux, CrudDetailView, MasterDetailCrud, Crud, CrudAux, MasterDetailCrud,
make_pagination, PermissionRequiredForAppCrudMixin) PermissionRequiredForAppCrudMixin, make_pagination)
from sapl.materia import apps from sapl.materia import apps
from sapl.materia.forms import AnexadaForm, LegislacaoCitadaForm,\ from sapl.materia.forms import (AnexadaForm, ConfirmarProposicaoForm,
TipoProposicaoForm, ProposicaoForm, ConfirmarProposicaoForm LegislacaoCitadaForm, ProposicaoForm,
TipoProposicaoForm)
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, 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)
import sapl
from .forms import (AcessorioEmLoteFilterSet, AcompanhamentoMateriaForm, from .forms import (AcessorioEmLoteFilterSet, AcompanhamentoMateriaForm,
DocumentoAcessorioForm, DocumentoAcessorioForm, MateriaLegislativaFilterSet,
MateriaLegislativaFilterSet, PrimeiraTramitacaoEmLoteFilterSet, ReceberProposicaoForm,
PrimeiraTramitacaoEmLoteFilterSet, ProposicaoOldForm, TramitacaoEmLoteFilterSet, filtra_tramitacao_destino,
ReceberProposicaoForm, TramitacaoEmLoteFilterSet,
filtra_tramitacao_destino,
filtra_tramitacao_destino_and_status, filtra_tramitacao_destino_and_status,
filtra_tramitacao_status) filtra_tramitacao_status)
from .models import (AcompanhamentoMateria, Anexada, Autoria, DespachoInicial, from .models import (AcompanhamentoMateria, Anexada, Autoria, DespachoInicial,
@ -58,7 +52,6 @@ from .models import (AcompanhamentoMateria, Anexada, Autoria, DespachoInicial,
TipoMateriaLegislativa, TipoProposicao, Tramitacao, TipoMateriaLegislativa, TipoProposicao, Tramitacao,
UnidadeTramitacao) UnidadeTramitacao)
OrigemCrud = Crud.build(Origem, '') OrigemCrud = Crud.build(Origem, '')
TipoMateriaCrud = CrudAux.build( TipoMateriaCrud = CrudAux.build(

2
sapl/norma/models.py

@ -143,8 +143,6 @@ class AssuntoNormaRelationship(models.Model):
unique_together = ( unique_together = (
('assunto', 'norma'), ('assunto', 'norma'),
) )
class Meta:
verbose_name = _('Assunto') verbose_name = _('Assunto')
verbose_name_plural = _('Assuntos') verbose_name_plural = _('Assuntos')

6
sapl/protocoloadm/models.py

@ -1,13 +1,9 @@
from uuid import uuid4
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
from sapl.base.models import Autor from sapl.base.models import Autor
from sapl.materia.models import TipoMateriaLegislativa, UnidadeTramitacao
from sapl.materia.models import (TipoMateriaLegislativa,
UnidadeTramitacao)
from sapl.utils import RANGE_ANOS, YES_NO_CHOICES, texto_upload_path from sapl.utils import RANGE_ANOS, YES_NO_CHOICES, texto_upload_path

2
sapl/protocoloadm/tests/test_protocoloadm.py

@ -1,10 +1,10 @@
import datetime import datetime
import pytest
from django.core.urlresolvers import reverse from django.core.urlresolvers import reverse
from django.utils.encoding import force_text from django.utils.encoding import force_text
from django.utils.translation import ugettext_lazy as _ from django.utils.translation import ugettext_lazy as _
from model_mommy import mommy from model_mommy import mommy
import pytest
from sapl.materia.models import UnidadeTramitacao from sapl.materia.models import UnidadeTramitacao
from sapl.protocoloadm.forms import AnularProcoloAdmForm from sapl.protocoloadm.forms import AnularProcoloAdmForm

9
sapl/protocoloadm/views.py

@ -12,12 +12,11 @@ from django.views.generic import CreateView, DetailView, FormView, ListView
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
import sapl
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.protocoloadm.apps import AppConfig
from sapl.utils import (create_barcode, get_client_ip, permissoes_adm, from sapl.utils import (create_barcode, get_client_ip, permissoes_adm,
permissoes_protocoloadm, permission_required_for_app) permissoes_protocoloadm)
import sapl
from .forms import (AnularProcoloAdmForm, DocumentoAcessorioAdministrativoForm, from .forms import (AnularProcoloAdmForm, DocumentoAcessorioAdministrativoForm,
DocumentoAdministrativoFilterSet, DocumentoAdministrativoFilterSet,
@ -28,7 +27,6 @@ from .models import (DocumentoAcessorioAdministrativo, DocumentoAdministrativo,
Protocolo, StatusTramitacaoAdministrativo, Protocolo, StatusTramitacaoAdministrativo,
TipoDocumentoAdministrativo, TramitacaoAdministrativo) TipoDocumentoAdministrativo, TramitacaoAdministrativo)
TipoDocumentoAdministrativoCrud = CrudAux.build( TipoDocumentoAdministrativoCrud = CrudAux.build(
TipoDocumentoAdministrativo, '') TipoDocumentoAdministrativo, '')
@ -49,7 +47,8 @@ class DocumentoAdministrativoMixin:
if app_config and app_config.documentos_administrativos == 'O': if app_config and app_config.documentos_administrativos == 'O':
return True return True
return self.request.user.has_module_perms(sapl.base.models.AppConfig.label) return self.request.user.has_module_perms(
sapl.base.models.AppConfig.label)
class DocumentoAdministrativoCrud(Crud): class DocumentoAdministrativoCrud(Crud):

2
sapl/relatorios/views.py

@ -19,7 +19,6 @@ from sapl.sessao.models import (ExpedienteMateria, ExpedienteSessao, Orador,
SessaoPlenariaPresenca, TipoExpediente) SessaoPlenariaPresenca, TipoExpediente)
from sapl.settings import STATIC_ROOT from sapl.settings import STATIC_ROOT
from sapl.utils import UF from sapl.utils import UF
import sapl
from .templates import (pdf_capa_processo_gerar, from .templates import (pdf_capa_processo_gerar,
pdf_documento_administrativo_gerar, pdf_espelho_gerar, pdf_documento_administrativo_gerar, pdf_espelho_gerar,
@ -27,7 +26,6 @@ from .templates import (pdf_capa_processo_gerar,
pdf_ordem_dia_gerar, pdf_pauta_sessao_gerar, pdf_ordem_dia_gerar, pdf_pauta_sessao_gerar,
pdf_protocolo_gerar, pdf_sessao_plenaria_gerar) pdf_protocolo_gerar, pdf_sessao_plenaria_gerar)
uf_dic = dict(UF) uf_dic = dict(UF)

21
sapl/rules/apps.py

@ -1,19 +1,20 @@
from builtins import LookupError from builtins import LookupError
import django
from django.apps import apps from django.apps import apps
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
from django.contrib.auth.management import _get_all_permissions from django.contrib.auth.management import _get_all_permissions
from django.core import exceptions from django.core import exceptions
from django.db import router, models from django.db import models, router
from django.db.models.signals import post_migrate
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 _
import django from django.utils.translation import string_concat
from sapl.rules import SAPL_GROUP_ADMINISTRATIVO, SAPL_GROUP_COMISSOES,\
SAPL_GROUP_GERAL, SAPL_GROUP_MATERIA, SAPL_GROUP_NORMA, SAPL_GROUP_PAINEL,\ from sapl.rules import (SAPL_GROUP_ADMINISTRATIVO, SAPL_GROUP_COMISSOES,
SAPL_GROUP_PROTOCOLO, SAPL_GROUP_SESSAO SAPL_GROUP_GERAL, SAPL_GROUP_MATERIA, SAPL_GROUP_NORMA,
SAPL_GROUP_PAINEL, SAPL_GROUP_PROTOCOLO,
SAPL_GROUP_SESSAO)
class AppConfig(django.apps.AppConfig): class AppConfig(django.apps.AppConfig):
@ -131,7 +132,8 @@ def update_groups(app_config, verbosity=2, interactive=True,
def associar(self, g, model, tipo): def associar(self, g, model, tipo):
for t in tipo: for t in tipo:
content_type = ContentType.objects.get_by_natural_key( content_type = ContentType.objects.get_by_natural_key(
app_label=model._meta.app_label, model=model._meta.model_name) app_label=model._meta.app_label,
model=model._meta.model_name)
codename = (t[1:] + model._meta.model_name)\ codename = (t[1:] + model._meta.model_name)\
if t[0] == '.' and t[-1] == '_' else t if t[0] == '.' and t[-1] == '_' else t
@ -185,7 +187,8 @@ def update_groups(app_config, verbosity=2, interactive=True,
if not isinstance(groups_name, list): if not isinstance(groups_name, list):
groups_name = [groups_name, ] groups_name = [groups_name, ]
for group_name in groups_name: for group_name in groups_name:
if not group_name or user.groups.filter(name=group_name).exists(): if not group_name or user.groups.filter(
name=group_name).exists():
continue continue
g = Group.objects.get_or_create(name=group_name)[0] g = Group.objects.get_or_create(name=group_name)[0]
user.groups.add(g) user.groups.add(g)

17
sapl/rules/map_rules.py

@ -1,24 +1,21 @@
from django.utils.translation import ugettext_lazy as _
from sapl.base import models as base from sapl.base import models as base
from sapl.comissoes import models as comissoes from sapl.comissoes import models as comissoes
from sapl.compilacao import models as compilacao from sapl.compilacao import models as compilacao
from sapl.crud.base import RP_LIST, RP_DETAIL, RP_ADD, RP_CHANGE, RP_DELETE from sapl.crud.base import RP_ADD, RP_CHANGE, RP_DELETE, RP_DETAIL, RP_LIST
from sapl.lexml import models as lexml from sapl.lexml import models as lexml
from sapl.materia import models as materia from sapl.materia import models as materia
from sapl.norma import models as norma from sapl.norma import models as norma
from sapl.painel import models as painel from sapl.painel import models as painel
from sapl.parlamentares import models as parlamentares from sapl.parlamentares import models as parlamentares
from sapl.protocoloadm import models as protocoloadm from sapl.protocoloadm import models as protocoloadm
from sapl.rules import SAPL_GROUP_ADMINISTRATIVO, SAPL_GROUP_GERAL,\ from sapl.rules import (SAPL_GROUP_ADMINISTRATIVO, SAPL_GROUP_ANONYMOUS,
SAPL_GROUP_PROTOCOLO, SAPL_GROUP_COMISSOES, SAPL_GROUP_MATERIA,\ SAPL_GROUP_AUTOR, SAPL_GROUP_COMISSOES,
SAPL_GROUP_ANONYMOUS, SAPL_GROUP_LOGIN_SOCIAL, SAPL_GROUP_NORMA,\ SAPL_GROUP_GERAL, SAPL_GROUP_LOGIN_SOCIAL,
SAPL_GROUP_AUTOR, SAPL_GROUP_PAINEL, SAPL_GROUP_SESSAO,\ SAPL_GROUP_MATERIA, SAPL_GROUP_NORMA,
SAPL_GROUP_PARLAMENTAR SAPL_GROUP_PAINEL, SAPL_GROUP_PARLAMENTAR,
SAPL_GROUP_PROTOCOLO, SAPL_GROUP_SESSAO)
from sapl.sessao import models as sessao from sapl.sessao import models as sessao
# RP = Radicao de Permissão # RP = Radicao de Permissão
__base__ = [RP_LIST, RP_DETAIL, RP_ADD, RP_CHANGE, RP_DELETE] __base__ = [RP_LIST, RP_DETAIL, RP_ADD, RP_CHANGE, RP_DELETE]
__listdetailchange__ = [RP_LIST, RP_DETAIL, RP_CHANGE] __listdetailchange__ = [RP_LIST, RP_DETAIL, RP_CHANGE]

3
sapl/rules/tests/test_rules.py

@ -1,15 +1,14 @@
import pytest
from django.apps import apps from django.apps import apps
from django.conf import settings from django.conf import settings
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.utils.translation import ugettext_lazy as _ from django.utils.translation import ugettext_lazy as _
import pytest
from sapl.rules import SAPL_GROUPS from sapl.rules import SAPL_GROUPS
from sapl.rules.map_rules import rules_patterns from sapl.rules.map_rules import rules_patterns
from sapl.test_urls import create_perms_post_migrate from sapl.test_urls import create_perms_post_migrate
sapl_appconfs = [apps.get_app_config(n[5:]) for n in settings.SAPL_APPS] sapl_appconfs = [apps.get_app_config(n[5:]) for n in settings.SAPL_APPS]
sapl_models = [] sapl_models = []

2
sapl/sessao/views.py

@ -2,7 +2,7 @@ from datetime import datetime
from re import sub from re import sub
from django.contrib import messages from django.contrib import messages
from django.core.exceptions import ObjectDoesNotExist, ValidationError from django.core.exceptions import ObjectDoesNotExist
from django.core.urlresolvers import reverse from django.core.urlresolvers import reverse
from django.forms.utils import ErrorList from django.forms.utils import ErrorList
from django.http import JsonResponse from django.http import JsonResponse

7
sapl/test_urls.py

@ -1,20 +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 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.rules.apps import update_groups, AppConfig from sapl.rules.apps import AppConfig, update_groups
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]

1
sapl/urls.py

@ -33,7 +33,6 @@ import sapl.protocoloadm.urls
import sapl.relatorios.urls import sapl.relatorios.urls
import sapl.sessao.urls import sapl.sessao.urls
urlpatterns = [ urlpatterns = [
url(r'^$', TemplateView.as_view(template_name='index.html')), url(r'^$', TemplateView.as_view(template_name='index.html')),
url(r'^admin/', include(admin.site.urls)), url(r'^admin/', include(admin.site.urls)),

23
sapl/utils.py

@ -1,12 +1,11 @@
from datetime import date
from functools import wraps
from unicodedata import normalize as unicodedata_normalize
import hashlib import hashlib
import hashlib
import logging
import logging import logging
import re import re
from datetime import date
from functools import wraps
from unicodedata import normalize as unicodedata_normalize
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
@ -15,19 +14,16 @@ from django.conf import settings
from django.contrib import admin 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.fields import GenericRelation, GenericRel,\ from django.contrib.contenttypes.fields import (GenericForeignKey, GenericRel,
GenericForeignKey GenericRelation)
from django.contrib.contenttypes.models import ContentType 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
import magic
import magic
from sapl.crispy_layout_mixin import SaplFormLayout, form_actions, to_row from sapl.crispy_layout_mixin import SaplFormLayout, form_actions, to_row
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)
@ -102,7 +98,12 @@ def montar_helper_autor(self):
class SaplGenericForeignKey(GenericForeignKey): class SaplGenericForeignKey(GenericForeignKey):
def __init__(self, ct_field='content_type', fk_field='object_id', for_concrete_model=True, verbose_name=''): def __init__(
self,
ct_field='content_type',
fk_field='object_id',
for_concrete_model=True,
verbose_name=''):
super().__init__(ct_field, fk_field, for_concrete_model) super().__init__(ct_field, fk_field, for_concrete_model)
self.verbose_name = verbose_name self.verbose_name = verbose_name

Loading…
Cancel
Save