mirror of https://github.com/interlegis/sapl.git
1 changed files with 27 additions and 0 deletions
@ -0,0 +1,27 @@ |
|||
# Generated by Django 2.2.20 on 2021-07-02 14:47 |
|||
|
|||
from django.db import migrations, models |
|||
|
|||
def atribuiMesaDiretora(apps, schema_editor): |
|||
sl_anterior = None |
|||
ComposicaoMesa = apps.get_model('parlamentares', 'ComposicaoMesa') |
|||
for c in ComposicaoMesa.objects.all().order_by('sessao_legislativa_id'): |
|||
if sl_anterior is None or c.sessao_legislativa_id != sl_anterior: |
|||
sl_anterior = c.sessao_legislativa_id |
|||
MesaDiretora = apps.get_model('parlamentares', 'MesaDiretora') |
|||
mesa_diretora = MesaDiretora(data_inicio=c.sessao_legislativa.data_inicio, |
|||
data_fim=c.sessao_legislativa.data_fim, |
|||
sessao_legislativa=c.sessao_legislativa) |
|||
c.mesa_diretora = mesa_diretora |
|||
mesa_diretora.save() |
|||
c.save() |
|||
|
|||
class Migration(migrations.Migration): |
|||
|
|||
dependencies = [ |
|||
('parlamentares', '0036_refatoraMesaDiretora'), |
|||
] |
|||
|
|||
operations = [ |
|||
migrations.RunPython(atribuiMesaDiretora) |
|||
] |
|||
Loading…
Reference in new issue