From 334be302de286cfb0fd68981893cf8d069b2b2e5 Mon Sep 17 00:00:00 2001 From: Eduardo Edson Batista Cordeiro Alves Date: Thu, 3 Nov 2016 14:40:28 -0200 Subject: [PATCH 1/3] =?UTF-8?q?Cria=20TemplateView=20ap=C3=B3s=20procola?= =?UTF-8?q?=C3=A7=C3=A3o?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- sapl/protocoloadm/urls.py | 3 +++ sapl/protocoloadm/views.py | 20 ++++++++++++++++--- .../protocoloadm/MateriaTemplate.html | 14 +++++++++++++ 3 files changed, 34 insertions(+), 3 deletions(-) create mode 100644 sapl/templates/protocoloadm/MateriaTemplate.html diff --git a/sapl/protocoloadm/urls.py b/sapl/protocoloadm/urls.py index 1de09a01a..21c627b06 100644 --- a/sapl/protocoloadm/urls.py +++ b/sapl/protocoloadm/urls.py @@ -10,6 +10,7 @@ from sapl.protocoloadm.views import (AnularProtocoloAdmView, DocumentoAdministrativoCrud, PesquisarDocumentoAdministrativoView, ProtocoloDocumentoView, + ProtocoloMateriaTemplateView, ProtocoloMateriaView, ProtocoloMostrarView, ProtocoloPesquisaView, @@ -60,6 +61,8 @@ urlpatterns_protocolo = [ + url(r'^protocoloadm/(?P\d+)/continuar$', + ProtocoloMateriaTemplateView.as_view(), name='materia_continuar'), url(r'^protocoloadm/anular-protocolo', diff --git a/sapl/protocoloadm/views.py b/sapl/protocoloadm/views.py index 5019d47bf..dd478b93a 100644 --- a/sapl/protocoloadm/views.py +++ b/sapl/protocoloadm/views.py @@ -312,8 +312,9 @@ class ProtocoloMateriaView(PermissionRequiredMixin, CreateView): form_valid_message = _('Matéria cadastrada com sucesso!') permission_required = ('protocoloadm.add_protocolo',) - def get_success_url(self): - return reverse('sapl.protocoloadm:protocolo') + def get_success_url(self, protocolo): + return reverse('sapl.protocoloadm:materia_continuar', kwargs={ + 'pk': protocolo.pk}) def form_valid(self, form): try: @@ -351,7 +352,20 @@ class ProtocoloMateriaView(PermissionRequiredMixin, CreateView): protocolo.numero_paginas = self.request.POST['numero_paginas'] protocolo.observacao = self.request.POST['observacao'] protocolo.save() - return redirect(self.get_success_url()) + return redirect(self.get_success_url(protocolo)) + + +class ProtocoloMateriaTemplateView(PermissionRequiredMixin, TemplateView): + + template_name = "protocoloadm/MateriaTemplate.html" + permission_required = ('protocoloadm.detail_protocolo', ) + + def get_context_data(self, **kwargs): + context = super(ProtocoloMateriaTemplateView, self).get_context_data( + **kwargs) + protocolo = Protocolo.objects.get(pk=self.kwargs['pk']) + context.update({'protocolo': protocolo}) + return context class PesquisarDocumentoAdministrativoView(DocumentoAdministrativoMixin, diff --git a/sapl/templates/protocoloadm/MateriaTemplate.html b/sapl/templates/protocoloadm/MateriaTemplate.html new file mode 100644 index 000000000..0af0ddbf9 --- /dev/null +++ b/sapl/templates/protocoloadm/MateriaTemplate.html @@ -0,0 +1,14 @@ +{% extends "base.html" %} +{% load i18n common_tags%} + +{% block base_content %} +Matéria procololada com sucesso! +
+Imprimir Etiqueta +Comprovante + +
+Criar Matéria +
+Continuar +{% endblock base_content %} From 608a8a381d9c12c8133e58852470469e2423a27c Mon Sep 17 00:00:00 2001 From: Eduardo Edson Batista Cordeiro Alves Date: Thu, 3 Nov 2016 14:59:58 -0200 Subject: [PATCH 2/3] Ajusta layout --- .../protocoloadm/MateriaTemplate.html | 29 +++++++++++++------ 1 file changed, 20 insertions(+), 9 deletions(-) diff --git a/sapl/templates/protocoloadm/MateriaTemplate.html b/sapl/templates/protocoloadm/MateriaTemplate.html index 0af0ddbf9..136b66cd6 100644 --- a/sapl/templates/protocoloadm/MateriaTemplate.html +++ b/sapl/templates/protocoloadm/MateriaTemplate.html @@ -2,13 +2,24 @@ {% load i18n common_tags%} {% block base_content %} -Matéria procololada com sucesso! -
-Imprimir Etiqueta -Comprovante - -
-Criar Matéria -
-Continuar + + +
+ Criar Matéria +

+ + + +
+ Continuar +
{% endblock base_content %} From cb2e602439fd847e9751367f8e4ccaba8b99ef05 Mon Sep 17 00:00:00 2001 From: Eduardo Edson Batista Cordeiro Alves Date: Thu, 3 Nov 2016 15:24:57 -0200 Subject: [PATCH 3/3] =?UTF-8?q?Cria=20mat=C3=A9ria=20com=20dados=20do=20pr?= =?UTF-8?q?otocolo?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- sapl/materia/forms.py | 30 +++++++++++++++- sapl/materia/urls.py | 7 +++- sapl/materia/views.py | 36 +++++++++++++++++-- .../protocoloadm/MateriaTemplate.html | 2 +- 4 files changed, 70 insertions(+), 5 deletions(-) diff --git a/sapl/materia/forms.py b/sapl/materia/forms.py index e95d38f8a..c46a6eb81 100644 --- a/sapl/materia/forms.py +++ b/sapl/materia/forms.py @@ -24,7 +24,8 @@ from sapl.base.models import Autor from sapl.comissoes.models import Comissao from sapl.crispy_layout_mixin import (SaplFormLayout, form_actions, to_column, to_row) -from sapl.materia.models import RegimeTramitacao, TipoDocumento, TipoProposicao +from sapl.materia.models import (MateriaLegislativa, RegimeTramitacao, + TipoDocumento, TipoProposicao) from sapl.norma.models import (LegislacaoCitada, NormaJuridica, TipoNormaJuridica) from sapl.parlamentares.models import Parlamentar @@ -66,6 +67,33 @@ class ReceberProposicaoForm(Form): super(ReceberProposicaoForm, self).__init__(*args, **kwargs) +class MateriaSimplificadaForm(ModelForm): + + class Meta: + model = MateriaLegislativa + fields = ['tipo', 'numero', 'ano', 'data_apresentacao', + 'numero_origem_externa', 'regime_tramitacao', + 'em_tramitacao', 'ementa', 'texto_original'] + + def __init__(self, *args, **kwargs): + + row1 = to_row([('tipo', 6), ('numero', 3), ('ano', 3)]) + row2 = to_row([('data_apresentacao', 6), ('numero_origem_externa', 6)]) + row3 = to_row([('regime_tramitacao', 6), ('em_tramitacao', 6)]) + row4 = to_row([('ementa', 12)]) + row5 = to_row([('texto_original', 12)]) + + self.helper = FormHelper() + self.helper.layout = Layout( + Fieldset( + _('Formulário Simplificado'), + row1, row2, row3, row4, row5, + form_actions(save_label='Salvar') + ) + ) + super(MateriaSimplificadaForm, self).__init__(*args, **kwargs) + + class UnidadeTramitacaoForm(ModelForm): class Meta: diff --git a/sapl/materia/urls.py b/sapl/materia/urls.py index c9e6a3270..9bfe31c5c 100644 --- a/sapl/materia/urls.py +++ b/sapl/materia/urls.py @@ -4,7 +4,8 @@ from sapl.materia.views import (AcompanhamentoConfirmarView, AcompanhamentoExcluirView, AcompanhamentoMateriaView, AnexadaCrud, AutoriaCrud, ConfirmarProposicao, - DespachoInicialCrud, DocumentoAcessorioCrud, + CriarProtocoloMateriaView, DespachoInicialCrud, + DocumentoAcessorioCrud, DocumentoAcessorioEmLoteView, LegislacaoCitadaCrud, MateriaLegislativaCrud, MateriaLegislativaPesquisaView, MateriaTaView, @@ -34,6 +35,10 @@ urlpatterns_materia = [ TramitacaoCrud.get_urls() + RelatoriaCrud.get_urls() + DocumentoAcessorioCrud.get_urls())), + + url(r'^materia/(?P[0-9]+)/create_simplificado$', + CriarProtocoloMateriaView.as_view(), + name='materia_create_simplificado'), url(r'^materia/recuperar-materia', recuperar_materia), url(r'^materia/(?P[0-9]+)/ta$', MateriaTaView.as_view(), name='materia_ta'), diff --git a/sapl/materia/views.py b/sapl/materia/views.py index 0e42c8a6e..9b6df196e 100644 --- a/sapl/materia/views.py +++ b/sapl/materia/views.py @@ -33,14 +33,16 @@ from sapl.materia.forms import (AnexadaForm, ConfirmarProposicaoForm, LegislacaoCitadaForm, ProposicaoForm, TipoProposicaoForm) from sapl.norma.models import LegislacaoCitada +from sapl.protocoloadm.models import Protocolo from sapl.utils import (TURNO_TRAMITACAO_CHOICES, YES_NO_CHOICES, autor_label, autor_modal, gerar_hash_arquivo, get_base_url, montar_row_autor) from .forms import (AcessorioEmLoteFilterSet, AcompanhamentoMateriaForm, DocumentoAcessorioForm, MateriaLegislativaFilterSet, - PrimeiraTramitacaoEmLoteFilterSet, ReceberProposicaoForm, - TramitacaoEmLoteFilterSet, filtra_tramitacao_destino, + MateriaSimplificadaForm, PrimeiraTramitacaoEmLoteFilterSet, + ReceberProposicaoForm, TramitacaoEmLoteFilterSet, + filtra_tramitacao_destino, filtra_tramitacao_destino_and_status, filtra_tramitacao_status) from .models import (AcompanhamentoMateria, Anexada, Autoria, DespachoInicial, @@ -65,6 +67,36 @@ TipoFimRelatoriaCrud = CrudAux.build( TipoFimRelatoria, 'fim_relatoria') +class CriarProtocoloMateriaView(CreateView): + template_name = "crud/form.html" + form_class = MateriaSimplificadaForm + form_valid_message = _('Matéria cadastrada com sucesso!') + + def get_success_url(self, materia): + return reverse('sapl.materia:materialegislativa_detail', kwargs={ + 'pk': materia.pk}) + + def get_context_data(self, **kwargs): + context = super( + CriarProtocoloMateriaView, self).get_context_data(**kwargs) + + protocolo = Protocolo.objects.get(pk=self.kwargs['pk']) + + context['form'].fields['tipo'].initial = protocolo.tipo_materia + context['form'].fields['numero'].initial = protocolo.numero + context['form'].fields['ano'].initial = protocolo.ano + context['form'].fields['data_apresentacao'].initial = protocolo.data + context['form'].fields[ + 'numero_origem_externa'].initial = protocolo.numero + context['form'].fields['ementa'].initial = protocolo.observacao + + return context + + def form_valid(self, form): + materia = form.save() + return redirect(self.get_success_url(materia)) + + class MateriaTaView(IntegracaoTaView): model = MateriaLegislativa model_type_foreignkey = TipoMateriaLegislativa diff --git a/sapl/templates/protocoloadm/MateriaTemplate.html b/sapl/templates/protocoloadm/MateriaTemplate.html index 136b66cd6..a23d718ad 100644 --- a/sapl/templates/protocoloadm/MateriaTemplate.html +++ b/sapl/templates/protocoloadm/MateriaTemplate.html @@ -7,7 +7,7 @@