mirror of https://github.com/interlegis/sigi.git
Sesostris Vieira
3 years ago
6 changed files with 96 additions and 6 deletions
@ -0,0 +1,18 @@ |
|||||
|
# Generated by Django 4.0.5 on 2022-06-30 17:21 |
||||
|
|
||||
|
from django.db import migrations, models |
||||
|
|
||||
|
|
||||
|
class Migration(migrations.Migration): |
||||
|
|
||||
|
dependencies = [ |
||||
|
('casas', '0024_delete_presidente'), |
||||
|
] |
||||
|
|
||||
|
operations = [ |
||||
|
migrations.AddField( |
||||
|
model_name='orgao', |
||||
|
name='telefone_geral', |
||||
|
field=models.CharField(blank=True, default='', help_text='Exemplo: <em>(31)8851-9898</em>.', max_length=64, verbose_name='telefone geral'), |
||||
|
), |
||||
|
] |
@ -0,0 +1,29 @@ |
|||||
|
# 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), |
||||
|
] |
File diff suppressed because one or more lines are too long
Loading…
Reference in new issue