diff --git a/korektury/migrations/0025_remove_oprava_autor_remove_oprava_text.py b/korektury/migrations/0025_remove_oprava_autor_remove_oprava_text.py new file mode 100644 index 00000000..82f23ba2 --- /dev/null +++ b/korektury/migrations/0025_remove_oprava_autor_remove_oprava_text.py @@ -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', + ), + ] diff --git a/korektury/models.py b/korektury/models.py index 5df14d6f..2f2480c1 100644 --- a/korektury/models.py +++ b/korektury/models.py @@ -157,20 +157,6 @@ class Oprava(models.Model): status = models.CharField(u'stav opravy',max_length=16, choices=STATUS.choices, blank=False, default = STATUS.K_OPRAVE) - autor = models.ForeignKey(Organizator, blank = True, - help_text='Autor opravy', - null = True, on_delete=models.SET_NULL) - - text = models.TextField(u'text opravy',blank = True, help_text='Text opravy') - -# def __init__(self,dictionary): -# for k,v in dictionary.items(): -# setattr(self,k,v) - - def __str__(self): - return '{} od {}: {}'.format(self.status,self.autor,self.text) - - @reversion.register(ignore_duplicates=True) class Komentar(models.Model): diff --git a/korektury/templates/korektury/opraf.html b/korektury/templates/korektury/opraf.html index 783c6910..176e6fe6 100644 --- a/korektury/templates/korektury/opraf.html +++ b/korektury/templates/korektury/opraf.html @@ -145,7 +145,6 @@