@ -12,12 +12,12 @@ 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
from sapl . base . apps import AppConfig as AppsAppConfig
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 . 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 )
permissoes_protocoloadm , permission_required_for_app )
import sapl
from . forms import ( AnularProcoloAdmForm , DocumentoAcessorioAdministrativoForm ,
from . forms import ( AnularProcoloAdmForm , DocumentoAcessorioAdministrativoForm ,
DocumentoAdministrativoFilterSet ,
DocumentoAdministrativoFilterSet ,
@ -28,6 +28,7 @@ from .models import (DocumentoAcessorioAdministrativo, DocumentoAdministrativo,
Protocolo , StatusTramitacaoAdministrativo ,
Protocolo , StatusTramitacaoAdministrativo ,
TipoDocumentoAdministrativo , TramitacaoAdministrativo )
TipoDocumentoAdministrativo , TramitacaoAdministrativo )
TipoDocumentoAdministrativoCrud = CrudAux . build (
TipoDocumentoAdministrativoCrud = CrudAux . build (
TipoDocumentoAdministrativo , ' ' )
TipoDocumentoAdministrativo , ' ' )
@ -44,11 +45,11 @@ DocumentoAcessorioAdministrativoCrud = Crud.build(
class DocumentoAdministrativoMixin :
class DocumentoAdministrativoMixin :
def has_permission ( self ) :
def has_permission ( self ) :
app_config = AppConfig . objects . last ( )
app_config = sapl . base . models . AppConfig . objects . last ( )
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 ( Apps AppConfig. label )
return self . request . user . has_module_perms ( sapl . base . models . AppConfig . label )
class DocumentoAdministrativoCrud ( Crud ) :
class DocumentoAdministrativoCrud ( Crud ) :
@ -82,7 +83,7 @@ class ProtocoloPesquisaView(PermissionRequiredMixin, FilterView):
model = Protocolo
model = Protocolo
filterset_class = ProtocoloFilterSet
filterset_class = ProtocoloFilterSet
paginate_by = 10
paginate_by = 10
permission_required = permissoes_protocoloadm ( )
permission_required = ( ' protocoloadm.list_protocolo ' , )
def get_filterset_kwargs ( self , filterset_class ) :
def get_filterset_kwargs ( self , filterset_class ) :
super ( ProtocoloPesquisaView ,
super ( ProtocoloPesquisaView ,
@ -143,7 +144,7 @@ class ProtocoloListView(PermissionRequiredMixin, ListView):
context_object_name = ' protocolos '
context_object_name = ' protocolos '
model = Protocolo
model = Protocolo
paginate_by = 10
paginate_by = 10
permission_required = permissoes_protocoloadm ( )
permission_required = ( ' protocoloadm.list_protocolo ' , )
def get_queryset ( self ) :
def get_queryset ( self ) :
kwargs = self . request . session [ ' kwargs ' ]
kwargs = self . request . session [ ' kwargs ' ]
@ -204,7 +205,8 @@ class ProtocoloDocumentoView(PermissionRequiredMixin,
f = form . save ( commit = False )
f = form . save ( commit = False )
try :
try :
numeracao = AppConfig . objects . last ( ) . sequencia_numeracao
numeracao = sapl . base . models . AppConfig . objects . last (
) . sequencia_numeracao
except AttributeError :
except AttributeError :
msg = _ ( ' É preciso definir a sequencia de ' +
msg = _ ( ' É preciso definir a sequencia de ' +
' numeração na tabelas auxiliares! ' )
' numeração na tabelas auxiliares! ' )
@ -326,7 +328,8 @@ class ProtocoloMateriaView(PermissionRequiredMixin, CreateView):
def form_valid ( self , form ) :
def form_valid ( self , form ) :
try :
try :
numeracao = AppConfig . objects . last ( ) . sequencia_numeracao
numeracao = sapl . base . models . AppConfig . objects . last (
) . sequencia_numeracao
except AttributeError :
except AttributeError :
msg = _ ( ' É preciso definir a sequencia de ' +
msg = _ ( ' É preciso definir a sequencia de ' +
' numeração na tabelas auxiliares! ' )
' numeração na tabelas auxiliares! ' )