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/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..a23d718ad --- /dev/null +++ b/sapl/templates/protocoloadm/MateriaTemplate.html @@ -0,0 +1,25 @@ +{% extends "base.html" %} +{% load i18n common_tags%} + +{% block base_content %} + + +
+ Criar Matéria +

+ + + +
+ Continuar +
+{% endblock base_content %}