Browse Source

Merge branch 'migrations_shuffle' of ssh://gimli.ms.mff.cuni.cz/akce/mam/git/mamweb into migrations_shuffle

middleware_test
Pavel Turinsky (DebianVM @ Zr) 3 years ago
parent
commit
070145eda4
  1. 10
      db_compare.py
  2. 10
      seminar/migrations/0058_problem_to_uloha_tema_clanek.py

10
db_compare.py

@ -309,7 +309,13 @@ def check_pohadka():
# Problémy jsou rozdělené podle typů: # Problémy jsou rozdělené podle typů:
def check_problem_common(): 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'] same_fields = ['id', 'nazev', 'stav', 'autor_id', 'kod']
renamed_fields = [ renamed_fields = [
@ -319,7 +325,7 @@ def check_problem_common():
old_fields = same_fields + [f[0] for f in renamed_fields] old_fields = same_fields + [f[0] for f in renamed_fields]
new_fields = same_fields + [f[1] 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) res = zip(old_res,new_res)
for o,n in res: for o,n in res:

10
seminar/migrations/0058_problem_to_uloha_tema_clanek.py

@ -57,7 +57,7 @@ def uloha_to_Uloha(apps,schema_editor):
max_body = uold.body, max_body = uold.body,
vytvoreno = uold.vytvoreno, 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()) unew.opravovatele.add(*uold.opravovatele.all())
# Nody: # Nody:
@ -101,9 +101,7 @@ def clanek_to_Clanek(apps,schema_editor):
cislo = cislo, cislo = cislo,
# Body ignorujeme, protože už jsou v hodnocení # Body ignorujeme, protože už jsou v hodnocení
) )
clnew.save() cl.save() # DULEZITE!!! Jinak Clanek.objects.create() přepíše všechny atributy Problému
cl.save()
def Clanek_Treenody(apps, schema_editor): def Clanek_Treenody(apps, schema_editor):
@ -170,6 +168,8 @@ def tema_to_Tema(apps, schema_editor):
TextNode = apps.get_model('seminar', 'TextNode') TextNode = apps.get_model('seminar', 'TextNode')
temata = Problem.objects.filter(Q(typ = 'tema') | Q(typ='serial')) 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: for t in temata:
# Vymyslíme správně ročník: # Vymyslíme správně ročník:
if t.cislo_zadani_old is None and t.cislo_reseni_old is None: if t.cislo_zadani_old is None and t.cislo_reseni_old is None:
@ -188,7 +188,7 @@ def tema_to_Tema(apps, schema_editor):
tema_typ = t.typ, tema_typ = t.typ,
rocnik = rocnik, rocnik = rocnik,
) )
tnew.save() t.save() # DULEZITE!!! Jinak Tema.objects.create() přepíše všechny atributy Problému
# Nody: # Nody:
tnode = TemaVCisleNode(tema = tnew) tnode = TemaVCisleNode(tema = tnew)

Loading…
Cancel
Save