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.
45 lines
1.6 KiB
45 lines
1.6 KiB
# Generated by Django 2.2.28 on 2026-04-13 13:49
|
|
|
|
from django.db import migrations, models
|
|
import django.db.models.deletion
|
|
|
|
def preencher_titulo_mesa_diretora(apps, schema_editor):
|
|
schema_editor.execute("""
|
|
UPDATE parlamentares_mesadiretora
|
|
SET titulo = 'Mesa Diretora' ||
|
|
CASE WHEN data_fim - data_inicio > 400
|
|
THEN ' Biênio'
|
|
ELSE ''
|
|
END || ' ' ||
|
|
EXTRACT(YEAR FROM data_inicio)::integer::text ||
|
|
CASE WHEN EXTRACT(YEAR FROM data_fim) <> EXTRACT(YEAR FROM data_inicio)
|
|
THEN '/' || EXTRACT(YEAR FROM data_fim)::integer::text
|
|
ELSE ''
|
|
END
|
|
WHERE data_inicio IS NOT NULL AND data_fim IS NOT NULL
|
|
""")
|
|
|
|
|
|
class Migration(migrations.Migration):
|
|
|
|
dependencies = [
|
|
('parlamentares', '0048_auto_20260412_2256'),
|
|
]
|
|
|
|
operations = [
|
|
migrations.AlterModelOptions(
|
|
name='mesadiretora',
|
|
options={'ordering': ('-legislatura', '-data_inicio'), 'verbose_name': 'Mesa Diretora', 'verbose_name_plural': 'Mesas Diretoras'},
|
|
),
|
|
migrations.AddField(
|
|
model_name='mesadiretora',
|
|
name='titulo',
|
|
field=models.CharField(default='', max_length=100, verbose_name='Título da Mesa Diretora'),
|
|
),
|
|
migrations.AlterField(
|
|
model_name='composicaomesa',
|
|
name='mesa_diretora',
|
|
field=models.ForeignKey(null=True, on_delete=django.db.models.deletion.PROTECT, related_name='composicaomesa_set', to='parlamentares.MesaDiretora'),
|
|
),
|
|
migrations.RunPython(preencher_titulo_mesa_diretora),
|
|
]
|
|
|