Oprava ztracenych nazvu problemu, pada migrace 60.
This commit is contained in:
parent
36c3cc6814
commit
c5b60c08f4
2 changed files with 13 additions and 7 deletions
|
@ -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:
|
||||
|
|
|
@ -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)
|
||||
|
|
Loading…
Reference in a new issue