From 1dc343d246fab65236340f8591fbf78342596a35 Mon Sep 17 00:00:00 2001 From: Luciano Almeida Date: Mon, 22 May 2017 11:16:34 -0300 Subject: [PATCH 1/2] Muda timestamp de norma pra null Signed-off-by: Luciano Almeida --- .../migrations/0004_auto_20170522_1115.py | 27 +++++++++++++++++++ sapl/norma/models.py | 2 +- 2 files changed, 28 insertions(+), 1 deletion(-) create mode 100644 sapl/norma/migrations/0004_auto_20170522_1115.py diff --git a/sapl/norma/migrations/0004_auto_20170522_1115.py b/sapl/norma/migrations/0004_auto_20170522_1115.py new file mode 100644 index 000000000..26e390bdb --- /dev/null +++ b/sapl/norma/migrations/0004_auto_20170522_1115.py @@ -0,0 +1,27 @@ +# -*- coding: utf-8 -*- +# Generated by Django 1.9.12 on 2017-05-22 11:15 +from __future__ import unicode_literals + +from django.db import migrations, models +import sapl.norma.models +import sapl.utils + + +class Migration(migrations.Migration): + + dependencies = [ + ('norma', '0003_auto_20170510_1549'), + ] + + operations = [ + migrations.AlterField( + model_name='normajuridica', + name='texto_integral', + field=models.FileField(blank=True, null=True, upload_to=sapl.norma.models.norma_upload_path, validators=[sapl.utils.restringe_tipos_de_arquivo_txt], verbose_name='Texto Integral'), + ), + migrations.AlterField( + model_name='normajuridica', + name='timestamp', + field=models.DateTimeField(null=True), + ), + ] diff --git a/sapl/norma/models.py b/sapl/norma/models.py index db552c9a9..20166e7f5 100644 --- a/sapl/norma/models.py +++ b/sapl/norma/models.py @@ -116,7 +116,7 @@ class NormaJuridica(models.Model): AssuntoNorma, blank=True, verbose_name=_('Assuntos')) data_vigencia = models.DateField(blank=True, null=True) - timestamp = models.DateTimeField() + timestamp = models.DateTimeField(null=True) texto_articulado = GenericRelation( TextoArticulado, related_query_name='texto_articulado') From 0b0bd3a166cfee56392e7077fdd90ad54fcb0d62 Mon Sep 17 00:00:00 2001 From: Luciano Almeida Date: Mon, 22 May 2017 11:18:48 -0300 Subject: [PATCH 2/2] =?UTF-8?q?Adiciona=20n=C3=BAmero=20da=20ordem=20do=20?= =?UTF-8?q?dia=20caso=20seja=20nulo?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Signed-off-by: Luciano Almeida --- sapl/legacy/migration.py | 21 +++++++++++++++++++-- 1 file changed, 19 insertions(+), 2 deletions(-) diff --git a/sapl/legacy/migration.py b/sapl/legacy/migration.py index c8e736694..7efa97f73 100644 --- a/sapl/legacy/migration.py +++ b/sapl/legacy/migration.py @@ -580,11 +580,27 @@ def migrate(obj=appconfs, interativo=True): # MIGRATION_ADJUSTMENTS ##################################################### -def adjust_ordemdia(new, old): +def adjust_ordemdia_antes_salvar(new, old): # Prestar atenção if not old.tip_votacao: new.tipo_votacao = 1 + if old.num_ordem is None: + new.numero_ordem = 999999999 + + +def adjust_ordemdia_depois_salvar(new, old): + if old.num_ordem is None and new.numero_ordem == 999999999: + with reversion.create_revision(): + problema = 'OrdemDia de PK %s tinha seu valor de numero ordem'\ + ' nulo.' % old.pk + descricao = 'O valor %s foi colocado no lugar.' % new.numero_ordem + warn(problema + ' => ' + descricao) + save_relation(obj=new, problema=problema, + descricao=descricao, eh_stub=False) + reversion.set_comment('OrdemDia sem número da ordem.') + pass + def adjust_parlamentar(new, old): if old.ind_unid_deliberativa: @@ -754,7 +770,7 @@ AJUSTE_ANTES_SALVAR = { Comissao: adjust_comissao, NormaJuridica: adjust_normajuridica_antes_salvar, NormaRelacionada: adjust_normarelacionada, - OrdemDia: adjust_ordemdia, + OrdemDia: adjust_ordemdia_antes_salvar, Parlamentar: adjust_parlamentar, Participacao: adjust_participacao, Protocolo: adjust_protocolo, @@ -767,6 +783,7 @@ AJUSTE_ANTES_SALVAR = { AJUSTE_DEPOIS_SALVAR = { NormaJuridica: adjust_normajuridica_depois_salvar, + OrdemDia: adjust_ordemdia_depois_salvar, Protocolo: adjust_protocolo_depois_salvar, RegistroVotacao: adjust_registrovotacao_depois_salvar, }