From c5b60c08f45b6d3efdb33350cd2dd7c47c9910df Mon Sep 17 00:00:00 2001 From: Tomas 'Jethro' Pokorny Date: Tue, 22 Jun 2021 23:11:00 +0200 Subject: [PATCH] Oprava ztracenych nazvu problemu, pada migrace 60. --- db_compare.py | 10 ++++++++-- .../migrations/0058_problem_to_uloha_tema_clanek.py | 10 +++++----- 2 files changed, 13 insertions(+), 7 deletions(-) diff --git a/db_compare.py b/db_compare.py index d4e1a777..0acd6808 100755 --- a/db_compare.py +++ b/db_compare.py @@ -286,7 +286,13 @@ def check_pohadka(): # Problémy jsou rozdělené podle typů: def check_problem_common(): - query = "SELECT * FROM seminar_problemy ORDER BY id" + old_query = "SELECT id, nazev, stav, kod, autor_id, text_org, timestamp, typ FROM seminar_problemy ORDER BY id" + new_query = """SELECT sp.id AS id, sp.nazev AS nazev, sp.stav AS stav, sp.kod AS kod, au.id AS autor_id, sp.poznamka AS poznamka, sp.vytvoreno AS vytvoreno + FROM seminar_problemy AS sp + LEFT OUTER JOIN seminar_organizator AS so ON sp.autor_id = so.id + LEFT OUTER JOIN seminar_osoby AS sos ON so.osoba_id = sos.id + LEFT OUTER JOIN auth_user AS au ON sos.user_id = au.id + ORDER BY sp.id""" same_fields = ['id', 'nazev', 'stav', 'autor_id', 'kod'] renamed_fields = [ @@ -296,7 +302,7 @@ def check_problem_common(): old_fields = same_fields + [f[0] for f in renamed_fields] new_fields = same_fields + [f[1] for f in renamed_fields] - old_res, new_res = execute_simple(query) + old_res, new_res = execute_simple(old_query,new_query) res = zip(old_res,new_res) for o,n in res: diff --git a/seminar/migrations/0058_problem_to_uloha_tema_clanek.py b/seminar/migrations/0058_problem_to_uloha_tema_clanek.py index 3c947b24..30a92e27 100644 --- a/seminar/migrations/0058_problem_to_uloha_tema_clanek.py +++ b/seminar/migrations/0058_problem_to_uloha_tema_clanek.py @@ -57,7 +57,7 @@ def uloha_to_Uloha(apps,schema_editor): max_body = uold.body, vytvoreno = uold.vytvoreno, ) - unew.save() + uold.save() # DULEZITE!!! Jinak Uloha.objects.create() přepíše všechny atributy Problému unew.opravovatele.add(*uold.opravovatele.all()) # Nody: @@ -101,9 +101,7 @@ def clanek_to_Clanek(apps,schema_editor): cislo = cislo, # Body ignorujeme, protože už jsou v hodnocení ) - clnew.save() - - cl.save() + cl.save() # DULEZITE!!! Jinak Clanek.objects.create() přepíše všechny atributy Problému # Vyrobíme nody: clnode = ClanekNode(clanek = clnew) @@ -118,6 +116,8 @@ def tema_to_Tema(apps, schema_editor): TextNode = apps.get_model('seminar', 'TextNode') temata = Problem.objects.filter(Q(typ = 'tema') | Q(typ='serial')) + #temata = Problem.objects.filter(id=635) + #temata = Problem.objects.filter(cislo_zadani_old__id=87) for t in temata: # Vymyslíme správně ročník: if t.cislo_zadani_old is None and t.cislo_reseni_old is None: @@ -136,7 +136,7 @@ def tema_to_Tema(apps, schema_editor): tema_typ = t.typ, rocnik = rocnik, ) - tnew.save() + t.save() # DULEZITE!!! Jinak Tema.objects.create() přepíše všechny atributy Problému # Nody: tnode = TemaVCisleNode(tema = tnew)