From d6544701e9a36a8982ddea05b32651bae760b85a Mon Sep 17 00:00:00 2001 From: "Tomas \"Jethro\" Pokorny" Date: Wed, 29 May 2019 00:27:03 +0200 Subject: [PATCH] Migrace Reseni a Hodnoceni. --- seminar/migrations/0049_auto_20190430_2354.py | 10 ++++---- .../0057_reseni_to_reseni_hodnoceni.py | 24 +++++++++++++++---- 2 files changed, 24 insertions(+), 10 deletions(-) diff --git a/seminar/migrations/0049_auto_20190430_2354.py b/seminar/migrations/0049_auto_20190430_2354.py index 239f86a8..2ee32f8a 100644 --- a/seminar/migrations/0049_auto_20190430_2354.py +++ b/seminar/migrations/0049_auto_20190430_2354.py @@ -176,6 +176,11 @@ class Migration(migrations.Migration): old_name='timestamp', new_name='vytvoreno', ), + migrations.RenameField( + model_name='reseni', + old_name='timestamp', + new_name='cas_doruceni', + ), migrations.RenameField( model_name='prilohareseni', old_name='timestamp', @@ -246,11 +251,6 @@ class Migration(migrations.Migration): name='opravovatele', field=models.ManyToManyField(blank=True, related_name='opravovatele_problem', to='seminar.Organizator', verbose_name='opravovatelé'), ), - migrations.AddField( - model_name='reseni', - name='cas_doruceni', - field=models.DateTimeField(blank=True, default=django.utils.timezone.now, verbose_name='čas_doručení'), - ), migrations.AddField( model_name='reseni', name='zverejneno', diff --git a/seminar/migrations/0057_reseni_to_reseni_hodnoceni.py b/seminar/migrations/0057_reseni_to_reseni_hodnoceni.py index 1a8b86ea..f266c923 100644 --- a/seminar/migrations/0057_reseni_to_reseni_hodnoceni.py +++ b/seminar/migrations/0057_reseni_to_reseni_hodnoceni.py @@ -4,12 +4,26 @@ from __future__ import unicode_literals from django.db import migrations +def reseni_to_Reseni(apps, schema_editor): + Reseni = apps.get_model('seminar','Reseni') + Hodnoceni = apps.get_model('seminar','Hodnoceni') + + for r in Reseni.objects.all(): + r.resitele.add(r.resitel) + h = Hodnoceni.objects.create(body=r.body) + h.cislo_body = r.cislo_body + h.problem = r.problem + h.reseni = r + h.save() + r.save() + class Migration(migrations.Migration): - dependencies = [ - ('seminar', '0056_vrcholy_pro_rocniky_a_cisla'), - ] + dependencies = [ + ('seminar', '0056_vrcholy_pro_rocniky_a_cisla'), + ] - operations = [ - ] + operations = [ + migrations.RunPython(reseni_to_Reseni) + ]