From 7a71fb40ea21fc8f1e4a54697a28dd286198bf94 Mon Sep 17 00:00:00 2001 From: "tapumar@gmail.com" Date: Wed, 28 Feb 2018 17:32:22 -0300 Subject: [PATCH] =?UTF-8?q?HOT-FIX:=20Gerar=20hash=20na=20edi=C3=A7=C3=A3o?= =?UTF-8?q?=20da=20proposi=C3=A7=C3=A3o?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- sapl/materia/forms.py | 13 ++++++++++--- 1 file changed, 10 insertions(+), 3 deletions(-) diff --git a/sapl/materia/forms.py b/sapl/materia/forms.py index 4b06957db..011181ec7 100644 --- a/sapl/materia/forms.py +++ b/sapl/materia/forms.py @@ -1,6 +1,5 @@ import os - import django_filters import sapl from crispy_forms.bootstrap import Alert, FormActions, InlineRadios @@ -23,7 +22,7 @@ from django.utils.encoding import force_text from django.utils.html import format_html from django.utils.safestring import mark_safe from django.utils.translation import ugettext_lazy as _ -from sapl.base.models import Autor, TipoAutor +from sapl.base.models import Autor, TipoAutor, AppConfig from sapl.comissoes.models import Comissao from sapl.compilacao.models import (STATUS_TA_IMMUTABLE_PUBLIC, STATUS_TA_PRIVATE) @@ -1235,6 +1234,7 @@ class ProposicaoForm(forms.ModelForm): def save(self, commit=True): cd = self.cleaned_data inst = self.instance + receber_recibo = AppConfig.objects.last().receber_recibo_proposicao if inst.pk: if 'tipo_texto' in cd: @@ -1249,6 +1249,13 @@ class ProposicaoForm(forms.ModelForm): not cd['texto_original'] and \ inst.texto_original: inst.texto_original.delete() + inst.save() + import ipdb; ipdb.set_trace() + if receber_recibo == True or not inst.texto_original: + inst.hash_code = '' + else: + _hash = gerar_hash_arquivo(inst.texto_original.path, str(inst.pk)) + inst.hash_code = _hash return super().save(commit) @@ -1261,7 +1268,7 @@ class ProposicaoForm(forms.ModelForm): numero__max + 1) if numero__max else 1 inst.save() - if cd['receber_recibo'] == 'True' or not inst.texto_original: + if receber_recibo == True or not inst.texto_original: inst.hash_code = '' else: _hash = gerar_hash_arquivo(inst.texto_original.path, str(inst.pk))