mirror of https://github.com/interlegis/sapl.git
5 changed files with 57 additions and 6 deletions
@ -0,0 +1,38 @@ |
|||||
|
# 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): |
||||
|
MesaDiretora = apps.get_model('parlamentares', 'MesaDiretora') |
||||
|
for mesa in MesaDiretora.objects.all(): |
||||
|
ano_inicio = mesa.data_inicio.year if mesa.data_inicio else None |
||||
|
ano_fim = mesa.data_fim.year if mesa.data_fim else None |
||||
|
if ano_inicio and ano_fim: |
||||
|
mesa.titulo = f'Mesa Diretora{" Biênio" if ano_fim - ano_inicio == 1 else ""} {ano_inicio}/{ano_fim}' |
||||
|
mesa.save() |
||||
|
|
||||
|
|
||||
|
class Migration(migrations.Migration): |
||||
|
|
||||
|
dependencies = [ |
||||
|
('parlamentares', '0047_auto_20260412_2256'), |
||||
|
] |
||||
|
|
||||
|
operations = [ |
||||
|
migrations.AlterModelOptions( |
||||
|
name='mesadiretora', |
||||
|
options={'ordering': ('-data_inicio', '-legislatura'), 'verbose_name': 'Mesa Diretora', 'verbose_name_plural': 'Mesas Diretoras'}, |
||||
|
), |
||||
|
migrations.AddField( |
||||
|
model_name='mesadiretora', |
||||
|
name='titulo', |
||||
|
field=models.CharField(default='', max_length=50, 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), |
||||
|
] |
||||
@ -0,0 +1 @@ |
|||||
|
{% extends "crud/list.html" %} |
||||
Loading…
Reference in new issue