Jonas Havelka
2 weeks ago
5 changed files with 51 additions and 33 deletions
@ -0,0 +1,45 @@ |
|||||
|
# Generated by Django 4.2.16 on 2024-12-12 10:25 |
||||
|
|
||||
|
from django.db import migrations |
||||
|
|
||||
|
import datetime |
||||
|
from django.utils import timezone |
||||
|
|
||||
|
|
||||
|
def oprava2komentar(apps, schema_editor): |
||||
|
Oprava = apps.get_model('korektury', 'Oprava') |
||||
|
Komentar = apps.get_model('korektury', 'Komentar') |
||||
|
|
||||
|
for o in Oprava.objects.all(): |
||||
|
Komentar.objects.create(oprava=o, text=o.text, autor=o.autor, cas=timezone.make_aware(datetime.datetime.fromtimestamp(0))) |
||||
|
|
||||
|
def komentar2oprava(apps, schema_editor): |
||||
|
Oprava = apps.get_model('korektury', 'Oprava') |
||||
|
Komentar = apps.get_model('korektury', 'Komentar') |
||||
|
|
||||
|
for o in Oprava.objects.all(): |
||||
|
k = Komentar.objects.filter(oprava=o).first() |
||||
|
o.text = k.text |
||||
|
o.autor = k.autor |
||||
|
o.save() |
||||
|
k.delete() |
||||
|
|
||||
|
|
||||
|
|
||||
|
class Migration(migrations.Migration): |
||||
|
|
||||
|
dependencies = [ |
||||
|
('korektury', '0024_vic_orgu_k_pdf'), |
||||
|
] |
||||
|
|
||||
|
operations = [ |
||||
|
migrations.RunPython(oprava2komentar, komentar2oprava), |
||||
|
migrations.RemoveField( |
||||
|
model_name='oprava', |
||||
|
name='autor', |
||||
|
), |
||||
|
migrations.RemoveField( |
||||
|
model_name='oprava', |
||||
|
name='text', |
||||
|
), |
||||
|
] |
Loading…
Reference in new issue