Web M&M
https://mam.matfyz.cz
43 lines
1.3 KiB
43 lines
1.3 KiB
2 years ago
|
# 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 = [
|
||
2 years ago
|
('seminar', '0112_prijemce_zasilat_cislo_emailem'),
|
||
2 years ago
|
]
|
||
|
|
||
|
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),
|
||
|
]
|