Jonas Havelka
2 years ago
6 changed files with 54 additions and 5 deletions
@ -0,0 +1,42 @@ |
|||
# 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), |
|||
] |
Loading…
Reference in new issue