|
@ -1,8 +1,9 @@ |
|
|
import json |
|
|
|
|
|
from datetime import date, datetime |
|
|
from datetime import date, datetime |
|
|
|
|
|
import json |
|
|
|
|
|
|
|
|
from braces.views import FormValidMessageMixin, PermissionRequiredMixin |
|
|
from braces.views import FormValidMessageMixin |
|
|
from django.contrib import messages |
|
|
from django.contrib import messages |
|
|
|
|
|
from django.contrib.auth.mixins import PermissionRequiredMixin |
|
|
from django.core.exceptions import ObjectDoesNotExist |
|
|
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, Q |
|
@ -13,14 +14,16 @@ 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.crud.base |
|
|
from sapl.base.apps import AppConfig as AppsAppConfig |
|
|
from sapl.base.models import AppConfig |
|
|
from sapl.base.models import AppConfig |
|
|
from sapl.crud.base import (Crud, CrudBaseMixin, CrudCreateView, |
|
|
from sapl.crud.base import (Crud, CrudBaseMixin, CrudCreateView, |
|
|
CrudDeleteView, CrudDetailView, CrudListView, |
|
|
CrudDeleteView, CrudDetailView, CrudListView, |
|
|
CrudUpdateView, MasterDetailCrud, make_pagination) |
|
|
CrudUpdateView, MasterDetailCrud, make_pagination, |
|
|
|
|
|
CrudAux) |
|
|
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, |
|
|
permissoes_protocoloadm) |
|
|
permissoes_protocoloadm) |
|
|
|
|
|
import sapl.crud.base |
|
|
|
|
|
|
|
|
from .forms import (AnularProcoloAdmForm, DocumentoAcessorioAdministrativoForm, |
|
|
from .forms import (AnularProcoloAdmForm, DocumentoAcessorioAdministrativoForm, |
|
|
DocumentoAdministrativoFilterSet, |
|
|
DocumentoAdministrativoFilterSet, |
|
@ -33,79 +36,57 @@ from .models import (Autor, DocumentoAcessorioAdministrativo, |
|
|
TipoDocumentoAdministrativo, TipoInstituicao, |
|
|
TipoDocumentoAdministrativo, TipoInstituicao, |
|
|
TramitacaoAdministrativo) |
|
|
TramitacaoAdministrativo) |
|
|
|
|
|
|
|
|
TipoDocumentoAdministrativoCrud = Crud.build(TipoDocumentoAdministrativo, '') |
|
|
|
|
|
DocumentoAcessorioAdministrativoCrud = Crud.build( |
|
|
TipoDocumentoAdministrativoCrud = CrudAux.build( |
|
|
DocumentoAcessorioAdministrativo, '') |
|
|
TipoDocumentoAdministrativo, '') |
|
|
|
|
|
TipoInstituicaoCrud = CrudAux.build(TipoInstituicao, '') |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
ProtocoloDocumentoCrud = Crud.build(Protocolo, '') |
|
|
ProtocoloDocumentoCrud = Crud.build(Protocolo, '') |
|
|
# FIXME precisa de uma chave diferente para o layout |
|
|
# FIXME precisa de uma chave diferente para o layout |
|
|
ProtocoloMateriaCrud = Crud.build(Protocolo, '') |
|
|
ProtocoloMateriaCrud = Crud.build(Protocolo, '') |
|
|
TipoInstituicaoCrud = Crud.build(TipoInstituicao, '') |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
class DocumentoAdministrativoCrud(Crud): |
|
|
DocumentoAcessorioAdministrativoCrud = Crud.build( |
|
|
model = DocumentoAdministrativo |
|
|
DocumentoAcessorioAdministrativo, '') |
|
|
help_path = '' |
|
|
|
|
|
|
|
|
|
|
|
class BaseMixin(sapl.crud.base.CrudBaseMixin): |
|
|
|
|
|
list_field_names = ['tipo', 'numero', 'ano', 'data', |
|
|
|
|
|
'numero_protocolo', 'assunto', |
|
|
|
|
|
'interessado', 'tramitacao', 'texto_integral'] |
|
|
|
|
|
|
|
|
|
|
|
class CreateView(CrudCreateView): |
|
|
|
|
|
permission_required = permissoes_adm() |
|
|
|
|
|
|
|
|
|
|
|
class UpdateView(CrudUpdateView): |
|
|
|
|
|
permission_required = permissoes_adm() |
|
|
|
|
|
|
|
|
|
|
|
class DeleteView(CrudDeleteView): |
|
|
class DocumentoAdministrativoMixin: |
|
|
permission_required = permissoes_adm() |
|
|
|
|
|
|
|
|
|
|
|
class ListView(CrudListView): |
|
|
|
|
|
permission_required = permissoes_adm() |
|
|
|
|
|
|
|
|
|
|
|
def has_permission(self): |
|
|
def has_permission(self): |
|
|
app_config = AppConfig.objects.last() |
|
|
app_config = AppConfig.objects.last() |
|
|
|
|
|
if app_config and app_config.documentos_administrativos == 'O': |
|
|
if app_config: |
|
|
|
|
|
if app_config.documentos_administrativos == 'O': |
|
|
|
|
|
return True |
|
|
return True |
|
|
|
|
|
|
|
|
perms = self.get_permission_required() |
|
|
return self.request.user.has_module_perms(AppsAppConfig.label) |
|
|
return self.request.user.has_perms(perms) |
|
|
|
|
|
|
|
|
|
|
|
class DetailView(CrudDetailView): |
|
|
|
|
|
permission_required = permissoes_adm() |
|
|
|
|
|
|
|
|
|
|
|
def has_permission(self): |
|
|
class DocumentoAdministrativoCrud(Crud): |
|
|
app_config = AppConfig.objects.last() |
|
|
model = DocumentoAdministrativo |
|
|
|
|
|
help_path = '' |
|
|
|
|
|
|
|
|
if app_config: |
|
|
class BaseMixin(Crud.BaseMixin): |
|
|
if app_config.documentos_administrativos == 'O': |
|
|
list_field_names = ['tipo', 'numero', 'ano', 'data', |
|
|
return True |
|
|
'numero_protocolo', 'assunto', |
|
|
|
|
|
'interessado', 'tramitacao', 'texto_integral'] |
|
|
|
|
|
|
|
|
perms = self.get_permission_required() |
|
|
class ListView(Crud.ListView, DocumentoAdministrativoMixin): |
|
|
return self.request.user.has_perms(perms) |
|
|
pass |
|
|
|
|
|
|
|
|
|
|
|
class DetailView(Crud.DetailView, DocumentoAdministrativoMixin): |
|
|
|
|
|
pass |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
class StatusTramitacaoAdministrativoCrud(Crud): |
|
|
class StatusTramitacaoAdministrativoCrud(CrudAux): |
|
|
model = StatusTramitacaoAdministrativo |
|
|
model = StatusTramitacaoAdministrativo |
|
|
help_path = '' |
|
|
help_path = '' |
|
|
|
|
|
|
|
|
class BaseMixin(CrudBaseMixin): |
|
|
class BaseMixin(CrudAux.BaseMixin): |
|
|
list_field_names = ['sigla', 'indicador', 'descricao'] |
|
|
list_field_names = ['sigla', 'indicador', 'descricao'] |
|
|
|
|
|
|
|
|
class ListView(CrudListView): |
|
|
class ListView(CrudAux.ListView): |
|
|
ordering = 'sigla' |
|
|
ordering = 'sigla' |
|
|
|
|
|
|
|
|
class CreateView(CrudCreateView): |
|
|
|
|
|
permission_required = permissoes_adm() |
|
|
|
|
|
|
|
|
|
|
|
class UpdateView(CrudUpdateView): |
|
|
|
|
|
permission_required = permissoes_adm() |
|
|
|
|
|
|
|
|
|
|
|
class DeleteView(CrudDeleteView): |
|
|
|
|
|
permission_required = permissoes_adm() |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
class ProtocoloPesquisaView(PermissionRequiredMixin, FilterView): |
|
|
class ProtocoloPesquisaView(PermissionRequiredMixin, FilterView): |
|
|
model = Protocolo |
|
|
model = Protocolo |
|
@ -392,22 +373,13 @@ class ProtocoloMateriaView(PermissionRequiredMixin, CreateView): |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
class PesquisarDocumentoAdministrativoView(PermissionRequiredMixin, |
|
|
class PesquisarDocumentoAdministrativoView(PermissionRequiredMixin, |
|
|
FilterView): |
|
|
FilterView, |
|
|
|
|
|
DocumentoAdministrativoMixin): |
|
|
model = DocumentoAdministrativo |
|
|
model = DocumentoAdministrativo |
|
|
filterset_class = DocumentoAdministrativoFilterSet |
|
|
filterset_class = DocumentoAdministrativoFilterSet |
|
|
paginate_by = 10 |
|
|
paginate_by = 10 |
|
|
permission_required = permissoes_adm() |
|
|
permission_required = permissoes_adm() |
|
|
|
|
|
|
|
|
def has_permission(self): |
|
|
|
|
|
app_config = AppConfig.objects.last() |
|
|
|
|
|
|
|
|
|
|
|
if app_config: |
|
|
|
|
|
if app_config.documentos_administrativos == 'O': |
|
|
|
|
|
return True |
|
|
|
|
|
|
|
|
|
|
|
perms = self.get_permission_required() |
|
|
|
|
|
return self.request.user.has_perms(perms) |
|
|
|
|
|
|
|
|
|
|
|
def get_filterset_kwargs(self, filterset_class): |
|
|
def get_filterset_kwargs(self, filterset_class): |
|
|
super(PesquisarDocumentoAdministrativoView, |
|
|
super(PesquisarDocumentoAdministrativoView, |
|
|
self).get_filterset_kwargs(filterset_class) |
|
|
self).get_filterset_kwargs(filterset_class) |
|
@ -603,45 +575,20 @@ class TramitacaoAdmCrud(MasterDetailCrud): |
|
|
|
|
|
|
|
|
class CreateView(MasterDetailCrud.CreateView): |
|
|
class CreateView(MasterDetailCrud.CreateView): |
|
|
form_class = TramitacaoAdmForm |
|
|
form_class = TramitacaoAdmForm |
|
|
permission_required = permissoes_adm() |
|
|
|
|
|
|
|
|
|
|
|
class UpdateView(MasterDetailCrud.UpdateView): |
|
|
class UpdateView(MasterDetailCrud.UpdateView): |
|
|
form_class = TramitacaoAdmEditForm |
|
|
form_class = TramitacaoAdmEditForm |
|
|
permission_required = permissoes_adm() |
|
|
|
|
|
|
|
|
|
|
|
class DeleteView(MasterDetailCrud.DeleteView): |
|
|
class ListView(MasterDetailCrud.ListView, DocumentoAdministrativoMixin): |
|
|
permission_required = permissoes_adm() |
|
|
|
|
|
|
|
|
|
|
|
class ListView(MasterDetailCrud.ListView): |
|
|
|
|
|
permission_required = permissoes_adm() |
|
|
|
|
|
|
|
|
|
|
|
def get_queryset(self): |
|
|
def get_queryset(self): |
|
|
qs = super(MasterDetailCrud.ListView, self).get_queryset() |
|
|
qs = super(MasterDetailCrud.ListView, self).get_queryset() |
|
|
kwargs = {self.crud.parent_field: self.kwargs['pk']} |
|
|
kwargs = {self.crud.parent_field: self.kwargs['pk']} |
|
|
return qs.filter(**kwargs).order_by('-data_tramitacao', '-id') |
|
|
return qs.filter(**kwargs).order_by('-data_tramitacao', '-id') |
|
|
|
|
|
|
|
|
def has_permission(self): |
|
|
class DetailView(MasterDetailCrud.DetailView, |
|
|
app_config = AppConfig.objects.last() |
|
|
DocumentoAdministrativoMixin): |
|
|
|
|
|
pass |
|
|
if app_config: |
|
|
|
|
|
if app_config.documentos_administrativos == 'O': |
|
|
|
|
|
return True |
|
|
|
|
|
|
|
|
|
|
|
perms = self.get_permission_required() |
|
|
|
|
|
return self.request.user.has_perms(perms) |
|
|
|
|
|
|
|
|
|
|
|
class DetailView(MasterDetailCrud.DetailView): |
|
|
|
|
|
permission_required = permissoes_adm() |
|
|
|
|
|
|
|
|
|
|
|
def has_permission(self): |
|
|
|
|
|
app_config = AppConfig.objects.last() |
|
|
|
|
|
|
|
|
|
|
|
if app_config: |
|
|
|
|
|
if app_config.documentos_administrativos == 'O': |
|
|
|
|
|
return True |
|
|
|
|
|
|
|
|
|
|
|
perms = self.get_permission_required() |
|
|
|
|
|
return self.request.user.has_perms(perms) |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
def get_nome_autor(request): |
|
|
def get_nome_autor(request): |
|
|