Browse Source

Merge branch '200-null-para-string-vazia'

pull/285/head
Marcio Mazza 9 years ago
parent
commit
4b5215181b
  1. 10
      legacy/migration.py
  2. 21
      parlamentares/migrations/0012_parlamentar_unidade_deliberativa.py
  3. 16
      parlamentares/migrations/0013_merge.py
  4. 3
      parlamentares/models.py
  5. 2
      sessao/legacy.yaml

10
legacy/migration.py

@ -159,6 +159,8 @@ class DataMigrator:
for field in new._meta.fields:
old_field_name = renames.get(field.name)
field_type = field.get_internal_type()
if old_field_name:
old_value = getattr(old, old_field_name)
if isinstance(field, models.ForeignKey):
@ -171,6 +173,14 @@ class DataMigrator:
value = get_fk_related(field, old_value, label)
else:
value = getattr(old, old_field_name)
if field_type == 'CharField' or field_type == 'TextField':
if value is None:
warn(
"Field %s (%s) from model %s"
" => settig empty string '' for %s value" %
(field.name, field_type, field.model.__name__,
value))
value = ''
setattr(new, field.name, value)
def migrate(self, obj=appconfs):

21
parlamentares/migrations/0012_parlamentar_unidade_deliberativa.py

@ -0,0 +1,21 @@
# -*- coding: utf-8 -*-
# Generated by Django 1.9 on 2016-03-07 17:58
from __future__ import unicode_literals
from django.db import migrations, models
class Migration(migrations.Migration):
dependencies = [
('parlamentares', '0011_auto_20160216_1015'),
]
operations = [
migrations.AddField(
model_name='parlamentar',
name='unidade_deliberativa',
field=models.BooleanField(default=True, verbose_name='Unidade Deliberativa'),
preserve_default=False,
),
]

16
parlamentares/migrations/0013_merge.py

@ -0,0 +1,16 @@
# -*- coding: utf-8 -*-
# Generated by Django 1.9 on 2016-03-10 17:06
from __future__ import unicode_literals
from django.db import migrations
class Migration(migrations.Migration):
dependencies = [
('parlamentares', '0012_parlamentar_unidade_deliberativa'),
('parlamentares', '0012_auto_20160307_0905'),
]
operations = [
]

3
parlamentares/models.py

@ -237,6 +237,9 @@ class Parlamentar(models.Model):
ativo = models.BooleanField(verbose_name=_('Ativo na Casa?'))
biografia = models.TextField(
blank=True, verbose_name=_('Biografia'))
# XXX Esse atribuito foi colocado aqui para não atrapalhar a migração
unidade_deliberativa = models.BooleanField(
verbose_name=_('Unidade Deliberativa'))
fotografia = models.ImageField(
blank=True,
null=True,

2
sessao/legacy.yaml

@ -76,4 +76,4 @@ VotoParlamentar (RegistroVotacaoParlamentar):
SessaoPlenariaPresenca:
data_sessao: dat_sessao
parlamentar: cod_parlamentar
sessao_plen: cod_sessao_plen
sessao_plenaria: cod_sessao_plen

Loading…
Cancel
Save