|
@ -9,7 +9,7 @@ from django.http import HttpResponseRedirect |
|
|
from django.shortcuts import redirect |
|
|
from django.shortcuts import redirect |
|
|
from django.utils.html import strip_tags |
|
|
from django.utils.html import strip_tags |
|
|
from django.utils.translation import ugettext_lazy as _ |
|
|
from django.utils.translation import ugettext_lazy as _ |
|
|
from django.views.generic import DetailView, ListView |
|
|
from django.views.generic import CreateView, DetailView, ListView |
|
|
from django.views.generic.base import TemplateView |
|
|
from django.views.generic.base import TemplateView |
|
|
from django.views.generic.edit import FormMixin |
|
|
from django.views.generic.edit import FormMixin |
|
|
from vanilla import GenericView |
|
|
from vanilla import GenericView |
|
@ -19,8 +19,9 @@ from materia.models import Proposicao, TipoMateriaLegislativa |
|
|
from sapl.utils import create_barcode |
|
|
from sapl.utils import create_barcode |
|
|
|
|
|
|
|
|
from .forms import (AnularProcoloAdmForm, DocumentoAcessorioAdministrativoForm, |
|
|
from .forms import (AnularProcoloAdmForm, DocumentoAcessorioAdministrativoForm, |
|
|
ProposicaoSimpleForm, ProtocoloDocumentForm, ProtocoloForm, |
|
|
DocumentoAdministrativoForm, ProposicaoSimpleForm, |
|
|
ProtocoloMateriaForm, TramitacaoAdmForm) |
|
|
ProtocoloDocumentForm, ProtocoloForm, ProtocoloMateriaForm, |
|
|
|
|
|
TramitacaoAdmForm) |
|
|
from .models import (Autor, DocumentoAcessorioAdministrativo, |
|
|
from .models import (Autor, DocumentoAcessorioAdministrativo, |
|
|
DocumentoAdministrativo, Protocolo, |
|
|
DocumentoAdministrativo, Protocolo, |
|
|
StatusTramitacaoAdministrativo, |
|
|
StatusTramitacaoAdministrativo, |
|
@ -302,6 +303,41 @@ class ProtocoloDocumentoView(FormMixin, GenericView): |
|
|
return self.form_invalid(form) |
|
|
return self.form_invalid(form) |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
def criar_documento(protocolo): |
|
|
|
|
|
doc = {} |
|
|
|
|
|
|
|
|
|
|
|
numero = Protocolo.objects.filter( |
|
|
|
|
|
tipo_documento=protocolo.tipo_documento, |
|
|
|
|
|
ano=protocolo.ano, |
|
|
|
|
|
anulado=False).aggregate(Max('numero')) |
|
|
|
|
|
|
|
|
|
|
|
doc['tipo'] = protocolo.tipo_documento |
|
|
|
|
|
doc['ano'] = protocolo.ano |
|
|
|
|
|
doc['data'] = protocolo.data |
|
|
|
|
|
doc['numero_protocolo'] = protocolo.numero |
|
|
|
|
|
doc['assunto'] = protocolo.assunto_ementa |
|
|
|
|
|
doc['interessado'] = protocolo.interessado |
|
|
|
|
|
doc['numero'] = numero['numero__max'] |
|
|
|
|
|
if doc['numero'] is None: |
|
|
|
|
|
doc['numero'] = 1 |
|
|
|
|
|
|
|
|
|
|
|
return doc |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
class CriarDocumentoProtocolo(CreateView): |
|
|
|
|
|
template_name = "protocoloadm/criar_documento.html" |
|
|
|
|
|
form_class = DocumentoAdministrativoForm |
|
|
|
|
|
|
|
|
|
|
|
def get_initial(self): |
|
|
|
|
|
numero = self.kwargs['pk'] |
|
|
|
|
|
ano = self.kwargs['ano'] |
|
|
|
|
|
protocolo = Protocolo.objects.get(ano=ano, numero=numero) |
|
|
|
|
|
return criar_documento(protocolo) |
|
|
|
|
|
|
|
|
|
|
|
def get_success_url(self): |
|
|
|
|
|
return reverse('detail_doc_adm', kwargs={'pk': self.object.pk}) |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
class ProtocoloMostrarView(TemplateView): |
|
|
class ProtocoloMostrarView(TemplateView): |
|
|
|
|
|
|
|
|
template_name = "protocoloadm/protocolo_mostrar.html" |
|
|
template_name = "protocoloadm/protocolo_mostrar.html" |
|
@ -516,63 +552,88 @@ class PesquisarDocumentoAdministrativo(TemplateView): |
|
|
class DetailDocumentoAdministrativo(DetailView): |
|
|
class DetailDocumentoAdministrativo(DetailView): |
|
|
template_name = "protocoloadm/detail_doc_adm.html" |
|
|
template_name = "protocoloadm/detail_doc_adm.html" |
|
|
|
|
|
|
|
|
def get_tipos_doc(self): |
|
|
|
|
|
return TipoDocumentoAdministrativo.objects.all() |
|
|
|
|
|
|
|
|
|
|
|
def get(self, request, *args, **kwargs): |
|
|
def get(self, request, *args, **kwargs): |
|
|
doc = DocumentoAdministrativo.objects.get(id=kwargs['pk']) |
|
|
documento = DocumentoAdministrativo.objects.get( |
|
|
|
|
|
id=self.kwargs['pk']) |
|
|
|
|
|
|
|
|
|
|
|
form = DocumentoAdministrativoForm( |
|
|
|
|
|
instance=documento) |
|
|
return self.render_to_response({ |
|
|
return self.render_to_response({ |
|
|
'pk': kwargs['pk'], |
|
|
'form': form, |
|
|
'doc': doc, |
|
|
'pk': kwargs['pk']}) |
|
|
'tipos_doc': TipoDocumentoAdministrativo.objects.all() |
|
|
|
|
|
}) |
|
|
|
|
|
|
|
|
|
|
|
def post(self, request, *args, **kwargs): |
|
|
def post(self, request, *args, **kwargs): |
|
|
|
|
|
|
|
|
if 'Salvar' in request.POST: |
|
|
if 'Salvar' in request.POST: |
|
|
documento = DocumentoAdministrativo.objects.get(id=kwargs['pk']) |
|
|
form = DocumentoAdministrativoForm(request.POST) |
|
|
|
|
|
|
|
|
if request.POST['numero']: |
|
|
|
|
|
documento.numero = request.POST['numero'] |
|
|
|
|
|
|
|
|
|
|
|
if request.POST['ano']: |
|
|
if form.is_valid(): |
|
|
documento.ano = request.POST['ano'] |
|
|
doc = form.save(commit=False) |
|
|
|
|
|
if 'texto_integral' in request.FILES: |
|
|
if request.POST['data']: |
|
|
doc.texto_integral = request.FILES['texto_integral'] |
|
|
documento.data = datetime.strptime( |
|
|
doc.save() |
|
|
request.POST['data'], "%d/%m/%Y") |
|
|
return self.form_valid(form) |
|
|
|
|
|
else: |
|
|
|
|
|
return self.render_to_response({'form': form}) |
|
|
|
|
|
elif 'Excluir' in request.POST: |
|
|
|
|
|
DocumentoAdministrativo.objects.get( |
|
|
|
|
|
id=kwargs['pk']).delete() |
|
|
|
|
|
return HttpResponseRedirect(self.get_success_delete()) |
|
|
|
|
|
|
|
|
if request.POST['numero_protocolo']: |
|
|
return HttpResponseRedirect(self.get_success_url()) |
|
|
documento.numero_protocolo = request.POST['numero_protocolo'] |
|
|
|
|
|
|
|
|
|
|
|
if request.POST['assunto']: |
|
|
def get_success_delete(self): |
|
|
documento.assunto = request.POST['assunto'] |
|
|
return reverse('pesq_doc_adm') |
|
|
|
|
|
|
|
|
if request.POST['interessado']: |
|
|
def get_success_url(self): |
|
|
documento.interessado = request.POST['interessado'] |
|
|
return reverse('detail_doc_adm', kwargs={ |
|
|
|
|
|
'pk': self.kwargs['pk']}) |
|
|
|
|
|
|
|
|
if request.POST['tramitacao']: |
|
|
|
|
|
documento.tramitacao = request.POST['tramitacao'] |
|
|
|
|
|
|
|
|
|
|
|
if request.POST['dias_prazo']: |
|
|
class DocumentoAcessorioAdministrativoEditView(FormMixin, GenericView): |
|
|
documento.dias_prazo = request.POST['dias_prazo'] |
|
|
template_name = "protocoloadm/documento_acessorio_administrativo_edit.html" |
|
|
|
|
|
|
|
|
if request.POST['data_fim_prazo']: |
|
|
def get(self, request, *args, **kwargs): |
|
|
documento.data_fim_prazo = datetime.strptime( |
|
|
doc = DocumentoAdministrativo.objects.get( |
|
|
request.POST['data_fim_prazo'], "%d/%m/%Y") |
|
|
id=kwargs['pk']) |
|
|
|
|
|
doc_ace = DocumentoAcessorioAdministrativo.objects.get( |
|
|
|
|
|
id=kwargs['ano']) |
|
|
|
|
|
form = DocumentoAcessorioAdministrativoForm(instance=doc_ace, |
|
|
|
|
|
excluir=True) |
|
|
|
|
|
|
|
|
if request.POST['observacao']: |
|
|
return self.render_to_response({'pk': self.kwargs['pk'], |
|
|
documento.observacao = request.POST['observacao'] |
|
|
'doc': doc, |
|
|
|
|
|
'doc_ace': doc_ace, |
|
|
|
|
|
'form': form}) |
|
|
|
|
|
|
|
|
documento.save() |
|
|
def post(self, request, *args, **kwargs): |
|
|
elif 'Excluir' in request.POST: |
|
|
form = DocumentoAcessorioAdministrativoForm(request.POST, excluir=True) |
|
|
DocumentoAdministrativo.objects.get( |
|
|
doc_ace = DocumentoAcessorioAdministrativo.objects.get( |
|
|
id=kwargs['pk']).delete() |
|
|
id=kwargs['ano']) |
|
|
|
|
|
|
|
|
return HttpResponseRedirect(self.get_success_url()) |
|
|
if form.is_valid(): |
|
|
|
|
|
if 'Salvar' in request.POST: |
|
|
|
|
|
if 'arquivo' in request.FILES: |
|
|
|
|
|
doc_ace.arquivo = request.FILES['arquivo'] |
|
|
|
|
|
doc_ace.documento = DocumentoAdministrativo.objects.get( |
|
|
|
|
|
id=kwargs['pk']) |
|
|
|
|
|
doc_ace.tipo = TipoDocumentoAdministrativo.objects.get( |
|
|
|
|
|
id=form.data['tipo']) |
|
|
|
|
|
doc_ace.nome = form.data['nome'] |
|
|
|
|
|
doc_ace.autor = form.data['autor'] |
|
|
|
|
|
doc_ace.data = datetime.strptime( |
|
|
|
|
|
form.data['data'], '%d/%m/%Y') |
|
|
|
|
|
doc_ace.assunto = form.data['assunto'] |
|
|
|
|
|
|
|
|
|
|
|
doc_ace.save() |
|
|
|
|
|
elif 'Excluir' in request.POST: |
|
|
|
|
|
doc_ace.delete() |
|
|
|
|
|
return self.form_valid(form) |
|
|
|
|
|
else: |
|
|
|
|
|
return self.form_invalid(form) |
|
|
|
|
|
|
|
|
def get_success_url(self): |
|
|
def get_success_url(self): |
|
|
return reverse('pesq_doc_adm') |
|
|
pk = self.kwargs['pk'] |
|
|
|
|
|
return reverse('doc_ace_adm', kwargs={'pk': pk}) |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
class DocumentoAcessorioAdministrativoView(FormMixin, GenericView): |
|
|
class DocumentoAcessorioAdministrativoView(FormMixin, GenericView): |
|
@ -583,10 +644,9 @@ class DocumentoAcessorioAdministrativoView(FormMixin, GenericView): |
|
|
doc = DocumentoAdministrativo.objects.get( |
|
|
doc = DocumentoAdministrativo.objects.get( |
|
|
id=kwargs['pk']) |
|
|
id=kwargs['pk']) |
|
|
doc_ace_null = '' |
|
|
doc_ace_null = '' |
|
|
try: |
|
|
doc_acessorio = DocumentoAcessorioAdministrativo.objects.filter( |
|
|
doc_acessorio = DocumentoAcessorioAdministrativo.objects.filter( |
|
|
documento_id=kwargs['pk']) |
|
|
documento_id=kwargs['pk']) |
|
|
if not doc_acessorio: |
|
|
except ObjectDoesNotExist: |
|
|
|
|
|
doc_ace_null = 'Nenhum documento acessório \ |
|
|
doc_ace_null = 'Nenhum documento acessório \ |
|
|
cadastrado para este processo.' |
|
|
cadastrado para este processo.' |
|
|
|
|
|
|
|
@ -599,17 +659,13 @@ class DocumentoAcessorioAdministrativoView(FormMixin, GenericView): |
|
|
def post(self, request, *args, **kwargs): |
|
|
def post(self, request, *args, **kwargs): |
|
|
form = DocumentoAcessorioAdministrativoForm(request.POST) |
|
|
form = DocumentoAcessorioAdministrativoForm(request.POST) |
|
|
if form.is_valid(): |
|
|
if form.is_valid(): |
|
|
doc_acessorio = DocumentoAcessorioAdministrativo() |
|
|
doc_ace = form.save(commit=False) |
|
|
doc_acessorio.tipo = form.cleaned_data['tipo'] |
|
|
if 'arquivo' in request.FILES: |
|
|
doc_acessorio.nome = form.cleaned_data['nome'] |
|
|
doc_ace.arquivo = request.FILES['arquivo'] |
|
|
doc_acessorio.data = form.cleaned_data['data'] |
|
|
doc = DocumentoAdministrativo.objects.get( |
|
|
doc_acessorio.autor = form.cleaned_data['autor'] |
|
|
|
|
|
doc_acessorio.assunto = form.cleaned_data['assunto'] |
|
|
|
|
|
doc_acessorio.arquivo = request.FILES['arquivo'] |
|
|
|
|
|
doc_acessorio.documento = DocumentoAdministrativo.objects.get( |
|
|
|
|
|
id=kwargs['pk']) |
|
|
id=kwargs['pk']) |
|
|
doc_acessorio.save() |
|
|
doc_ace.documento = doc |
|
|
|
|
|
doc_ace.save() |
|
|
return self.form_valid(form) |
|
|
return self.form_valid(form) |
|
|
else: |
|
|
else: |
|
|
return self.form_invalid(form) |
|
|
return self.form_invalid(form) |
|
|