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
14fdf6cb53
  1. 29
      db_compare.py
  2. 2
      seminar/migrations/0049_auto_20190430_2354.py

29
db_compare.py

@ -254,12 +254,19 @@ def check_novinky():
def check_pohadka(): def check_pohadka():
old_query = "SELECT * FROM seminar_pohadky ORDER BY id" old_query = "SELECT * FROM seminar_pohadky ORDER BY id"
new_query = """SELECT sp.id AS id, sp.autor_id AS autor_id, sp.vytvoreno AS vytvoreno, snp.treenode_ptr_id AS treenode_ptr_id, st.na_web AS text new_query = """SELECT sp.id AS id, sp.autor_id AS autor_id, sp.vytvoreno AS vytvoreno, snp.treenode_ptr_id AS treenode_ptr_id, st.na_web AS text,
zn_pred.uloha_id AS uloha_pred, zn_po.uloha_id AS uloha_po
FROM seminar_pohadky AS sp FROM seminar_pohadky AS sp
-- Text pohádky
INNER JOIN seminar_nodes_pohadka AS snp ON sp.id = snp.pohadka_id INNER JOIN seminar_nodes_pohadka AS snp ON sp.id = snp.pohadka_id
INNER JOIN seminar_nodes_treenode AS snt ON snt.id = snp.treenode_ptr_id INNER JOIN seminar_nodes_treenode AS snt ON snt.id = snp.treenode_ptr_id
INNER JOIN seminar_nodes_obsah AS sno ON sno.treenode_ptr_id = snt.first_child_id INNER JOIN seminar_nodes_obsah AS sno ON sno.treenode_ptr_id = snt.first_child_id
INNER JOIN seminar_texty AS st ON sno.text_id = st.id INNER JOIN seminar_texty AS st ON sno.text_id = st.id
-- Predchozí úloha
LEFT OUTER JOIN seminar_nodes_treenode AS ztn_pred ON ztn_pred.succ_id = snt.id
LEFT OUTER JOIN seminar_nodes_uloha_zadani AS zn_pred ON zn_pred.treenode_ptr_id = ztn_pred.id
-- Následující úloha
LEFT OUTER JOIN seminar_nodes_uloha_zadani AS zn_po ON zn_po.treenode_ptr_id = snt.succ_id
ORDER BY sp.id""" ORDER BY sp.id"""
@ -271,6 +278,10 @@ def check_pohadka():
if o['autor_id'] is not None: if o['autor_id'] is not None:
if get_user_id_for_org_id(n['autor_id']) != o['autor_id']: if get_user_id_for_org_id(n['autor_id']) != o['autor_id']:
raise ValueError("Nesedi autori u pohadky") raise ValueError("Nesedi autori u pohadky")
# Správné úlohy
spravny_klic = 'uloha_pred' if o['pred'] else 'uloha_po'
if o['uloha_id'] != n[spravny_klic]:
raise ValueError(f"Pohádka přidružená ke špatné úloze! old: {o['uloha_id']}, new: {n[spravny_klic]}, pozice: {spravny_klic}")
# Problémy jsou rozdělené podle typů: # Problémy jsou rozdělené podle typů:
@ -310,24 +321,24 @@ def check_problem_common():
def check_uloha(): def check_uloha():
old_query = "SELECT * FROM seminar_problemy WHERE typ = 'uloha' ORDER BY id" old_query = "SELECT * FROM seminar_problemy WHERE typ = 'uloha' ORDER BY id"
new_query = """SELECT cislo_zadani, cislo_reseni, problem_ptr_id, max_body, uzt.na_web AS text_zadani, uvt.na_web AS text_reseni new_query = """SELECT cislo_zadani_id, cislo_reseni_id, problem_ptr_id, max_body, uzt.na_web AS text_zadani, uvt.na_web AS text_reseni
FROM seminar_ulohy FROM seminar_ulohy
-- Problém: -- Problém:
JOIN seminar_problemy AS problem ON problem_ptr_id = problem.id JOIN seminar_problemy AS problem ON problem_ptr_id = problem.id
-- Text zadání: -- Text zadání:
INNER JOIN seminar_nodes_uloha_zadani AS uzn ON id = uzn.uloha_id INNER JOIN seminar_nodes_uloha_zadani AS uzn ON problem.id = uzn.uloha_id
INNER JOIN seminar_nodes_treenode AS uztn ON uztn.id = uzn.treenode_ptr_id INNER JOIN seminar_nodes_treenode AS uztn ON uztn.id = uzn.treenode_ptr_id
INNER JOIN seminar_nodes_obsah AS uzo ON uzo.treenode_ptr_id = uztn.first_child_id INNER JOIN seminar_nodes_obsah AS uzo ON uzo.treenode_ptr_id = uztn.first_child_id
INNER JOIN seminar_texty AS uzt ON uzo.text_id = uzt.id INNER JOIN seminar_texty AS uzt ON uzo.text_id = uzt.id
-- Text vzoráku: -- Text vzoráku:
INNER JOIN seminar_nodes_uloha_zadani AS uvn ON id = uvn.uloha_id INNER JOIN seminar_nodes_uloha_zadani AS uvn ON problem.id = uvn.uloha_id
INNER JOIN seminar_nodes_treenode AS uvtn ON uvtn.id = uvn.treenode_ptr_id INNER JOIN seminar_nodes_treenode AS uvtn ON uvtn.id = uvn.treenode_ptr_id
INNER JOIN seminar_nodes_obsah AS uvo ON uvo.treenode_ptr_id = uvtn.first_child_id INNER JOIN seminar_nodes_obsah AS uvo ON uvo.treenode_ptr_id = uvtn.first_child_id
INNER JOIN seminar_texty AS uvt ON uvo.text_id = uvt.id INNER JOIN seminar_texty AS uvt ON uvo.text_id = uvt.id
ORDER BY problem_ptr_id""" ORDER BY problem_ptr_id"""
same_fields = ['cislo_zadani', 'cislo_reseni', 'text_zadani', 'text_reseni'] same_fields = ['cislo_zadani_id', 'cislo_reseni_id', 'text_zadani', 'text_reseni']
renamed_fields = [ renamed_fields = [
('id', 'problem_ptr_id'), ('id', 'problem_ptr_id'),
('body', 'max_body'), ('body', 'max_body'),
@ -349,7 +360,7 @@ def check_tema():
FROM seminar_problemy FROM seminar_problemy
INNER JOIN seminar_cisla AS c ON c.id = cislo_zadani_id INNER JOIN seminar_cisla AS c ON c.id = cislo_zadani_id
WHERE typ IN ('tema', 'serial') WHERE typ IN ('tema', 'serial')
ORDER BY id""" ORDER BY seminar_problemy.id"""
new_query = """SELECT tema_typ, zad_text.na_web AS text_zadani, res_text.na_web AS text_reseni, rn.rocnik_id AS rocnik_id new_query = """SELECT tema_typ, zad_text.na_web AS text_zadani, res_text.na_web AS text_reseni, rn.rocnik_id AS rocnik_id
FROM seminar_temata FROM seminar_temata
-- Problém: -- Problém:
@ -408,10 +419,10 @@ def check_res_clanek():
JOIN seminar_problemy AS problem ON problem_ptr_id = problem.id JOIN seminar_problemy AS problem ON problem_ptr_id = problem.id
INNER JOIN seminar_hodnoceni AS hodn ON problem.id = hodn.problem_id INNER JOIN seminar_hodnoceni AS hodn ON problem.id = hodn.problem_id
INNER JOIN seminar_reseni AS rese ON rese.id = hodn.reseni_id INNER JOIN seminar_reseni AS rese ON rese.id = hodn.reseni_id
INNER JOIN seminar_nodes_reseni AS resnode ON resnode.reseni_id = rese.id INNER JOIN seminar_nodes_otistene_reseni AS resnode ON resnode.reseni_id = rese.id
INNER JOIN seminar_nodes_treenode AS tn ON resnode.treenode_ptr_id = tn.id INNER JOIN seminar_nodes_treenode AS tn ON resnode.treenode_ptr_id = tn.id
INNER JOIN seminar_nodes_obsah AS on ON on.treenode_ptr_id = tn.first_child_id INNER JOIN seminar_nodes_obsah AS son ON son.treenode_ptr_id = tn.first_child_id
INNER JOIN seminar_texty AS text ON text.id = on.text_id INNER JOIN seminar_texty AS text ON text.id = son.text_id
ORDER BY problem_ptr_id""" ORDER BY problem_ptr_id"""
same_fields = ['text_zadani'] same_fields = ['text_zadani']

2
seminar/migrations/0049_auto_20190430_2354.py

@ -63,7 +63,7 @@ class Migration(migrations.Migration):
('id', models.AutoField(primary_key=True, serialize=False)), ('id', models.AutoField(primary_key=True, serialize=False)),
('jmeno', models.CharField(max_length=256, verbose_name='jméno')), ('jmeno', models.CharField(max_length=256, verbose_name='jméno')),
('prijmeni', models.CharField(max_length=256, verbose_name='příjmení')), ('prijmeni', models.CharField(max_length=256, verbose_name='příjmení')),
('prezdivka', models.CharField(max_length=256, verbose_name='přezdívka')), ('prezdivka', models.CharField(max_length=256, verbose_name='přezdívka', blank=True, null=False)),
('pohlavi_muz', models.BooleanField(default=False, verbose_name='pohlaví (muž)')), ('pohlavi_muz', models.BooleanField(default=False, verbose_name='pohlaví (muž)')),
('email', models.EmailField(blank=True, default='', max_length=256, verbose_name='e-mail')), ('email', models.EmailField(blank=True, default='', max_length=256, verbose_name='e-mail')),
('telefon', models.CharField(blank=True, default='', max_length=256, verbose_name='telefon')), ('telefon', models.CharField(blank=True, default='', max_length=256, verbose_name='telefon')),

Loading…
Cancel
Save