mirror of https://github.com/interlegis/sigi.git
Sesostris Vieira
2 years ago
6 changed files with 58 additions and 8 deletions
@ -0,0 +1,20 @@ |
|||||
|
# -*- coding: utf-8 -*- |
||||
|
from __future__ import unicode_literals |
||||
|
|
||||
|
from django.db import models, migrations |
||||
|
|
||||
|
|
||||
|
class Migration(migrations.Migration): |
||||
|
|
||||
|
dependencies = [ |
||||
|
('eventos', '0017_auto_20220413_0900'), |
||||
|
] |
||||
|
|
||||
|
operations = [ |
||||
|
migrations.AddField( |
||||
|
model_name='evento', |
||||
|
name='turma', |
||||
|
field=models.CharField(max_length=100, verbose_name='Turma', blank=True), |
||||
|
preserve_default=True, |
||||
|
), |
||||
|
] |
@ -0,0 +1,29 @@ |
|||||
|
# -*- coding: utf-8 -*- |
||||
|
from __future__ import unicode_literals |
||||
|
|
||||
|
from django.db import models, migrations |
||||
|
|
||||
|
def separa_turma(apps, schema_editor): |
||||
|
Evento = apps.get_model("eventos", "Evento") |
||||
|
for evento in Evento.objects.filter(nome__icontains='Turma'): |
||||
|
split_name = evento.nome.rsplit('-', 1) |
||||
|
if len(split_name) == 2: |
||||
|
evento.nome = split_name[0].strip() |
||||
|
evento.turma = split_name[1].strip() |
||||
|
evento.save() |
||||
|
|
||||
|
def junta_turma(apps, schema_editor): |
||||
|
Evento = apps.get_model("eventos", "Evento") |
||||
|
for evento in Evento.objects.exclude(turma=''): |
||||
|
evento.nome = evento.nome + ' - ' + evento.turma |
||||
|
evento.save() |
||||
|
|
||||
|
class Migration(migrations.Migration): |
||||
|
|
||||
|
dependencies = [ |
||||
|
('eventos', '0018_evento_turma'), |
||||
|
] |
||||
|
|
||||
|
operations = [ |
||||
|
migrations.RunPython(separa_turma, junta_turma), |
||||
|
] |
Loading…
Reference in new issue