Jonas Havelka
3 years ago
2 changed files with 47 additions and 4 deletions
@ -0,0 +1,43 @@ |
|||||
|
# Generated by Django 2.2.24 on 2021-09-16 13:09 |
||||
|
|
||||
|
from django.db import migrations, models |
||||
|
import django.db.models.deletion |
||||
|
|
||||
|
|
||||
|
def force_osoby(apps, schema_editor): |
||||
|
typy_osob = [ |
||||
|
'Resitel', |
||||
|
'Organizator' |
||||
|
] |
||||
|
for typ in typy_osob: |
||||
|
model = apps.get_model('seminar', typ) |
||||
|
pocet = model.objects.filter(osoba=None).count() |
||||
|
if pocet > 0: |
||||
|
# myslím, že je nejde nijak pořádně identifikovat |
||||
|
raise ValueError(str(pocet) + " " + typ + "ů nemá osobu") |
||||
|
|
||||
|
|
||||
|
class Migration(migrations.Migration): |
||||
|
dependencies = [ |
||||
|
('seminar', '0001_squashed_0098_auto_20210906_0305'), |
||||
|
] |
||||
|
|
||||
|
operations = [ |
||||
|
migrations.RunPython(force_osoby, migrations.RunPython.noop), |
||||
|
migrations.AlterField( |
||||
|
model_name='organizator', |
||||
|
name='osoba', |
||||
|
field=models.OneToOneField( |
||||
|
help_text='osobní údaje organizátora', |
||||
|
on_delete=django.db.models.deletion.PROTECT, |
||||
|
related_name='org', to='seminar.Osoba', |
||||
|
verbose_name='osoba'), |
||||
|
), |
||||
|
migrations.AlterField( |
||||
|
model_name='resitel', |
||||
|
name='osoba', |
||||
|
field=models.OneToOneField( |
||||
|
on_delete=django.db.models.deletion.PROTECT, |
||||
|
to='seminar.Osoba', verbose_name='osoba'), |
||||
|
), |
||||
|
] |
Loading…
Reference in new issue