From e0db6e1dc0ecce2d25a52830f17c19907b8c26c6 Mon Sep 17 00:00:00 2001 From: Marcio Mazza Date: Tue, 23 Feb 2016 09:50:12 -0300 Subject: [PATCH] =?UTF-8?q?Conserta=20mapeamento=20de=20campos=20de=20migr?= =?UTF-8?q?a=C3=A7=C3=A3o=20do=20legado?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- legacy/migration.py | 11 ++++++++++- legacy/test_renames.py | 8 ++++++++ materia/legacy.yaml | 2 -- sapl/test_general.py | 4 ++-- sapl/utils.py | 12 ++++++------ scripts/convert_null_to_empty_in_all_char_fields.py | 4 ++-- 6 files changed, 28 insertions(+), 13 deletions(-) diff --git a/legacy/migration.py b/legacy/migration.py index 677e66b95..6ccd362cf 100644 --- a/legacy/migration.py +++ b/legacy/migration.py @@ -11,11 +11,20 @@ from model_mommy import mommy from comissoes.models import Composicao, Participacao from parlamentares.models import Parlamentar -from sapl.utils import appconfs from sessao.models import SessaoPlenaria # BASE ###################################################################### +# apps to be migrated, in app dependency order (very important) +appconfs = [apps.get_app_config(n) for n in [ + 'parlamentares', + 'comissoes', + 'materia', + 'norma', + 'sessao', + 'lexml', + 'protocoloadm', ]] + name_sets = [set(m.__name__ for m in ac.get_models()) for ac in appconfs] # apps do not overlap diff --git a/legacy/test_renames.py b/legacy/test_renames.py index 89ca9b15b..473f39567 100644 --- a/legacy/test_renames.py +++ b/legacy/test_renames.py @@ -1,21 +1,29 @@ import comissoes import materia +import norma import sessao from .migration import appconfs, get_renames, legacy_app RENAMING_IGNORED_MODELS = [ comissoes.models.Composicao, + norma.models.AssuntoNormaRelationship, + + # FIXME retirar daqui depois que a issue #218 for resolvida!!!!!!! + sessao.models.AcompanharMateria, ] RENAMING_IGNORED_FIELDS = [ (comissoes.models.Participacao, {'composicao'}), (materia.models.Proposicao, {'documento'}), (materia.models.TipoProposicao, {'tipo_documento'}), + (materia.models.Tramitacao, {'ultima'}), (sessao.models.SessaoPlenaria, {'finalizada', 'upload_pauta', 'upload_ata', 'iniciada'}), + (sessao.models.ExpedienteMateria, {'votacao_aberta'}), + (sessao.models.OrdemDia, {'votacao_aberta'}), ] diff --git a/materia/legacy.yaml b/materia/legacy.yaml index b5c9b3e6c..4e883c317 100644 --- a/materia/legacy.yaml +++ b/materia/legacy.yaml @@ -95,7 +95,6 @@ Numeracao: data_materia: dat_materia materia: cod_materia numero_materia: num_materia - numero_ordem: num_ordem tipo_materia: tip_materia Orgao: @@ -158,7 +157,6 @@ Tramitacao: status: cod_status texto: txt_tramitacao turno: sgl_turno - ultima: ind_ult_tramitacao unidade_tramitacao_destino: cod_unid_tram_dest unidade_tramitacao_local: cod_unid_tram_local urgente: ind_urgencia diff --git a/sapl/test_general.py b/sapl/test_general.py index 35587f3c9..5c2e0bf9b 100644 --- a/sapl/test_general.py +++ b/sapl/test_general.py @@ -1,7 +1,7 @@ import pytest from model_mommy import mommy -from .utils import appconfs +from .utils import sapl_appconfs pytestmark = pytest.mark.django_db @@ -9,7 +9,7 @@ pytestmark = pytest.mark.django_db def test_str_sanity(): # this simply a sanity check # __str__ semantics is not considered and should be tested separetely - for app in appconfs: + for app in sapl_appconfs: for model in app.get_models(): obj = mommy.prepare(model) try: diff --git a/sapl/utils.py b/sapl/utils.py index 6f9c48c46..0d8dfa904 100644 --- a/sapl/utils.py +++ b/sapl/utils.py @@ -2,18 +2,18 @@ from django.apps import apps from django.contrib import admin from django.utils.translation import ugettext_lazy as _ -# SAPL business apps -# This is a dependency order: each entry depends only on previous ones -# The order is important for migration code -appconfs = [apps.get_app_config(n) for n in [ +# SAPL business apps in dependency order +# (each entry depends only on previous ones) +sapl_appconfs = [apps.get_app_config(n) for n in [ 'parlamentares', 'comissoes', - 'compilacao', 'materia', 'norma', 'sessao', 'lexml', - 'protocoloadm', ]] + 'protocoloadm', + 'compilacao', +]] def register_all_models_in_admin(module_name): diff --git a/scripts/convert_null_to_empty_in_all_char_fields.py b/scripts/convert_null_to_empty_in_all_char_fields.py index 2f4e03a89..6f21f885e 100644 --- a/scripts/convert_null_to_empty_in_all_char_fields.py +++ b/scripts/convert_null_to_empty_in_all_char_fields.py @@ -1,10 +1,10 @@ from django.db import models -from sapl.utils import appconfs +from sapl.utils import sapl_appconfs def convert_null_to_empty(): - for app in appconfs: + for app in sapl_appconfs: for model in app.get_models(): print('Convertendo null p/ vazio. model [%s]' % model._meta.model_name)