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.
 
 
 
 
 
 

42 lines
1.3 KiB

# Generated by Django 2.2.28 on 2023-03-13 22:02
from django.db import migrations, models
ZASILAT_DOMU = 'domu'
ZASILAT_DO_SKOLY = 'do_skoly'
ZASILAT_NIKAM = 'nikam'
def default_zasilat_papirove(apps, schema_editor):
Resitel = apps.get_model('seminar', 'Resitel')
for resitel in Resitel.objects.all():
resitel.zasilat_cislo_papirove = resitel.zasilat != ZASILAT_NIKAM
if resitel.zasilat == ZASILAT_NIKAM:
resitel.zasilat = ZASILAT_DOMU if resitel.osoba.ulice else ZASILAT_DO_SKOLY
resitel.save()
def vrat_nikam(apps, schema_editor):
Resitel = apps.get_model('seminar', 'Resitel')
for resitel in Resitel.objects.all():
if not resitel.zasilat_cislo_papirove:
resitel.zasilat = ZASILAT_NIKAM
resitel.save()
class Migration(migrations.Migration):
dependencies = [
('seminar', '0111_nikam2nezasilat_papirove'),
]
operations = [
migrations.AddField(
model_name='resitel',
name='zasilat_cislo_papirove',
field=models.BooleanField(default=True, help_text='True pokud chce řešitel dostávat číslo papírově', verbose_name='zasílat číslo papírově'),
),
migrations.RunPython(default_zasilat_papirove, vrat_nikam),
]