From d8d3ef878122397dda5b2802a1185fb2507e5bdb Mon Sep 17 00:00:00 2001 From: Eduardo Calil Date: Mon, 22 May 2017 13:54:30 -0300 Subject: [PATCH] Bug Fix --- sapl/materia/views.py | 18 +++++++++++++++--- sapl/protocoloadm/views.py | 1 + 2 files changed, 16 insertions(+), 3 deletions(-) diff --git a/sapl/materia/views.py b/sapl/materia/views.py index 006e2cd88..4ff498cec 100644 --- a/sapl/materia/views.py +++ b/sapl/materia/views.py @@ -162,14 +162,26 @@ class CriarProtocoloMateriaView(CreateView): context = super( CriarProtocoloMateriaView, self).get_context_data(**kwargs) - protocolo = Protocolo.objects.get(pk=self.kwargs['pk']) + try: + protocolo = Protocolo.objects.get(pk=self.kwargs['pk']) + except ObjectDoesNotExist: + raise Http404() + + materias_ano = MateriaLegislativa.objects.filter( + ano=protocolo.ano, + tipo=protocolo.tipo_materia).order_by('-numero') + + if materias_ano: + numero = materias_ano.first().numero + 1 + else: + numero = 1 context['form'].fields['tipo'].initial = protocolo.tipo_materia - context['form'].fields['numero'].initial = protocolo.numero + context['form'].fields['numero'].initial = numero context['form'].fields['ano'].initial = protocolo.ano context['form'].fields['data_apresentacao'].initial = protocolo.data context['form'].fields['numero_protocolo'].initial = protocolo.numero - context['form'].fields['ementa'].initial = protocolo.observacao + context['form'].fields['ementa'].initial = protocolo.assunto_ementa return context diff --git a/sapl/protocoloadm/views.py b/sapl/protocoloadm/views.py index 9505f3bd9..b50edaaf0 100644 --- a/sapl/protocoloadm/views.py +++ b/sapl/protocoloadm/views.py @@ -425,6 +425,7 @@ class ProtocoloMateriaView(PermissionRequiredMixin, CreateView): id=self.request.POST['tipo_materia']) protocolo.numero_paginas = self.request.POST['numero_paginas'] protocolo.observacao = self.request.POST['observacao'] + protocolo.assunto_ementa = self.request.POST['assunto_ementa'] protocolo.save() return redirect(self.get_success_url(protocolo))