mirror of https://github.com/interlegis/sigi.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.
29 lines
787 B
29 lines
787 B
# Generated by Django 4.0.5 on 2022-06-30 17:26
|
|
|
|
from django.db import migrations
|
|
|
|
|
|
def carrega_telefone_geral(apps, schema_editor):
|
|
Orgao = apps.get_model("casas", "Orgao")
|
|
Telefone = apps.get_model("contatos", "Telefone")
|
|
telefones = Telefone.objects.filter(
|
|
content_type__app_label="casas", content_type__model="orgao"
|
|
)
|
|
for orgao in Orgao.objects.all():
|
|
telefone = (
|
|
telefones.filter(object_id=orgao.id).exclude(numero="").first()
|
|
)
|
|
if telefone:
|
|
orgao.telefone_geral = telefone.numero
|
|
orgao.save()
|
|
|
|
|
|
class Migration(migrations.Migration):
|
|
|
|
dependencies = [
|
|
("casas", "0025_orgao_telefone_geral"),
|
|
]
|
|
|
|
operations = [
|
|
migrations.RunPython(carrega_telefone_geral),
|
|
]
|
|
|