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 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

8
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'}),
]

2
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

4
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:

12
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):

4
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)

Loading…
Cancel
Save