Browse Source

Conserta mapeamento de campos de migração do legado

pull/237/head
Marcio Mazza 9 years ago
parent
commit
e0db6e1dc0
  1. 11
      legacy/migration.py
  2. 8
      legacy/test_renames.py
  3. 2
      materia/legacy.yaml
  4. 4
      sapl/test_general.py
  5. 12
      sapl/utils.py
  6. 4
      scripts/convert_null_to_empty_in_all_char_fields.py

11
legacy/migration.py

@ -11,11 +11,20 @@ from model_mommy import mommy
from comissoes.models import Composicao, Participacao from comissoes.models import Composicao, Participacao
from parlamentares.models import Parlamentar from parlamentares.models import Parlamentar
from sapl.utils import appconfs
from sessao.models import SessaoPlenaria from sessao.models import SessaoPlenaria
# BASE ###################################################################### # 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] name_sets = [set(m.__name__ for m in ac.get_models()) for ac in appconfs]
# apps do not overlap # apps do not overlap

8
legacy/test_renames.py

@ -1,21 +1,29 @@
import comissoes import comissoes
import materia import materia
import norma
import sessao import sessao
from .migration import appconfs, get_renames, legacy_app from .migration import appconfs, get_renames, legacy_app
RENAMING_IGNORED_MODELS = [ RENAMING_IGNORED_MODELS = [
comissoes.models.Composicao, comissoes.models.Composicao,
norma.models.AssuntoNormaRelationship,
# FIXME retirar daqui depois que a issue #218 for resolvida!!!!!!!
sessao.models.AcompanharMateria,
] ]
RENAMING_IGNORED_FIELDS = [ RENAMING_IGNORED_FIELDS = [
(comissoes.models.Participacao, {'composicao'}), (comissoes.models.Participacao, {'composicao'}),
(materia.models.Proposicao, {'documento'}), (materia.models.Proposicao, {'documento'}),
(materia.models.TipoProposicao, {'tipo_documento'}), (materia.models.TipoProposicao, {'tipo_documento'}),
(materia.models.Tramitacao, {'ultima'}),
(sessao.models.SessaoPlenaria, {'finalizada', (sessao.models.SessaoPlenaria, {'finalizada',
'upload_pauta', 'upload_pauta',
'upload_ata', 'upload_ata',
'iniciada'}), 'iniciada'}),
(sessao.models.ExpedienteMateria, {'votacao_aberta'}),
(sessao.models.OrdemDia, {'votacao_aberta'}),
] ]

2
materia/legacy.yaml

@ -95,7 +95,6 @@ Numeracao:
data_materia: dat_materia data_materia: dat_materia
materia: cod_materia materia: cod_materia
numero_materia: num_materia numero_materia: num_materia
numero_ordem: num_ordem
tipo_materia: tip_materia tipo_materia: tip_materia
Orgao: Orgao:
@ -158,7 +157,6 @@ Tramitacao:
status: cod_status status: cod_status
texto: txt_tramitacao texto: txt_tramitacao
turno: sgl_turno turno: sgl_turno
ultima: ind_ult_tramitacao
unidade_tramitacao_destino: cod_unid_tram_dest unidade_tramitacao_destino: cod_unid_tram_dest
unidade_tramitacao_local: cod_unid_tram_local unidade_tramitacao_local: cod_unid_tram_local
urgente: ind_urgencia urgente: ind_urgencia

4
sapl/test_general.py

@ -1,7 +1,7 @@
import pytest import pytest
from model_mommy import mommy from model_mommy import mommy
from .utils import appconfs from .utils import sapl_appconfs
pytestmark = pytest.mark.django_db pytestmark = pytest.mark.django_db
@ -9,7 +9,7 @@ pytestmark = pytest.mark.django_db
def test_str_sanity(): def test_str_sanity():
# this simply a sanity check # this simply a sanity check
# __str__ semantics is not considered and should be tested separetely # __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(): for model in app.get_models():
obj = mommy.prepare(model) obj = mommy.prepare(model)
try: try:

12
sapl/utils.py

@ -2,18 +2,18 @@ from django.apps import apps
from django.contrib import admin from django.contrib import admin
from django.utils.translation import ugettext_lazy as _ from django.utils.translation import ugettext_lazy as _
# SAPL business apps # SAPL business apps in dependency order
# This is a dependency order: each entry depends only on previous ones # (each entry depends only on previous ones)
# The order is important for migration code sapl_appconfs = [apps.get_app_config(n) for n in [
appconfs = [apps.get_app_config(n) for n in [
'parlamentares', 'parlamentares',
'comissoes', 'comissoes',
'compilacao',
'materia', 'materia',
'norma', 'norma',
'sessao', 'sessao',
'lexml', 'lexml',
'protocoloadm', ]] 'protocoloadm',
'compilacao',
]]
def register_all_models_in_admin(module_name): def register_all_models_in_admin(module_name):

4
scripts/convert_null_to_empty_in_all_char_fields.py

@ -1,10 +1,10 @@
from django.db import models from django.db import models
from sapl.utils import appconfs from sapl.utils import sapl_appconfs
def convert_null_to_empty(): def convert_null_to_empty():
for app in appconfs: for app in sapl_appconfs:
for model in app.get_models(): for model in app.get_models():
print('Convertendo null p/ vazio. model [%s]' print('Convertendo null p/ vazio. model [%s]'
% model._meta.model_name) % model._meta.model_name)

Loading…
Cancel
Save