From d84c8aae0d994fd595f524375ec9ceb4f3584892 Mon Sep 17 00:00:00 2001 From: Cesar Augusto de Carvalho Date: Wed, 13 Feb 2019 13:46:47 -0200 Subject: [PATCH] =?UTF-8?q?Fix=20#2459=20-=20Proposi=C3=A7=C3=B5es=20sem?= =?UTF-8?q?=20c=C3=B3digo=20ap=C3=B3s=20mudar=20a=20configura=C3=A7=C3=A3o?= =?UTF-8?q?=20(#2464)?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit * fix #2459 * fix #2459 * fix #2459 --- sapl/base/views.py | 24 ++++++++++++++++--- .../materia/prop_pendentes_list.html | 2 +- 2 files changed, 22 insertions(+), 4 deletions(-) diff --git a/sapl/base/views.py b/sapl/base/views.py index 3bc003cc0..04db2ab3d 100644 --- a/sapl/base/views.py +++ b/sapl/base/views.py @@ -32,12 +32,12 @@ from sapl.base.forms import AutorForm, AutorFormForAdmin, TipoAutorForm from sapl.base.models import Autor, TipoAutor from sapl.comissoes.models import Reuniao, Comissao from sapl.crud.base import CrudAux, make_pagination -from sapl.materia.models import (Autoria, MateriaLegislativa, +from sapl.materia.models import (Autoria, MateriaLegislativa, Proposicao, TipoMateriaLegislativa, StatusTramitacao, UnidadeTramitacao) from sapl.norma.models import (NormaJuridica, NormaEstatisticas) from sapl.sessao.models import (PresencaOrdemDia, SessaoPlenaria, SessaoPlenariaPresenca) -from sapl.utils import (parlamentares_ativos, +from sapl.utils import (parlamentares_ativos, gerar_hash_arquivo, SEPARADOR_HASH_PROPOSICAO, show_results_filter_set, mail_service_configured) from .forms import (AlterarSenhaForm, CasaLegislativaForm, @@ -1078,10 +1078,28 @@ class AppConfigCrud(CrudAux): class BaseMixin(CrudAux.BaseMixin): form_class = ConfiguracoesAppForm - list_url = '' create_url = '' + def form_valid(self, form): + recibo_prop_atual = AppConfig.objects.last().receber_recibo_proposicao + recibo_prop_novo = self.request.POST['receber_recibo_proposicao'] + if recibo_prop_novo == 'False' and recibo_prop_atual: + props = Proposicao.objects.filter(hash_code='') + for prop in props: + self.gerar_hash(prop) + return super().form_valid(form) + + def gerar_hash(self, inst): + inst.save() + if inst.texto_original: + inst.hash_code = gerar_hash_arquivo( + inst.texto_original.path, str(inst.pk)) + elif inst.texto_articulado.exists(): + ta = inst.texto_articulado.first() + inst.hash_code = 'P' + ta.hash() + SEPARADOR_HASH_PROPOSICAO + str(inst.pk) + inst.save() + class CreateView(CrudAux.CreateView): def get(self, request, *args, **kwargs): diff --git a/sapl/templates/materia/prop_pendentes_list.html b/sapl/templates/materia/prop_pendentes_list.html index 251c4ed22..b940333d2 100644 --- a/sapl/templates/materia/prop_pendentes_list.html +++ b/sapl/templates/materia/prop_pendentes_list.html @@ -57,7 +57,7 @@ {{ prop.autor }} {% if not AppConfig.receber_recibo_proposicao %} - {%if prop.hash_code %} + {% if prop.hash_code %} {{ prop.hash_code }} {% else %} {{ prop.hash_code }}