mirror of https://github.com/interlegis/sapl.git
You can not select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
46 lines
1.5 KiB
46 lines
1.5 KiB
# -*- coding: utf-8 -*-
|
|
# Generated by Django 1.9.13 on 2018-01-31 12:14
|
|
from __future__ import unicode_literals
|
|
|
|
from django.db import migrations, models
|
|
|
|
from sapl.utils import LISTA_DE_UFS
|
|
|
|
|
|
def migrate_municipio_e_uf_como_charfields(apps, schema_editor):
|
|
Parlamentar = apps.get_model('parlamentares', 'Parlamentar')
|
|
for parlamentar in Parlamentar.objects.all():
|
|
municipio = parlamentar.municipio_residencia_old
|
|
if municipio:
|
|
parlamentar.municipio_residencia = municipio.nome
|
|
parlamentar.uf_residencia = municipio.uf
|
|
parlamentar.save()
|
|
|
|
|
|
class Migration(migrations.Migration):
|
|
|
|
dependencies = [
|
|
('parlamentares', '0013_auto_20180130_1425'),
|
|
]
|
|
|
|
operations = [
|
|
migrations.RenameField(
|
|
model_name='parlamentar',
|
|
old_name='municipio_residencia',
|
|
new_name='municipio_residencia_old',
|
|
),
|
|
|
|
migrations.AddField(
|
|
model_name='parlamentar',
|
|
name='municipio_residencia',
|
|
field=models.CharField(blank=True, max_length=50,
|
|
verbose_name='Município'),
|
|
),
|
|
migrations.AddField(
|
|
model_name='parlamentar',
|
|
name='uf_residencia',
|
|
field=models.CharField(blank=True, choices=LISTA_DE_UFS,
|
|
max_length=2, verbose_name='UF'),
|
|
),
|
|
migrations.RunPython(migrate_municipio_e_uf_como_charfields),
|
|
]
|
|
|