Merge branch 'migrations_shuffle' of gimli.ms.mff.cuni.cz:/akce/mam/git/mamweb into migrations_shuffle
This commit is contained in:
commit
a52840d46c
1 changed files with 95 additions and 4 deletions
|
@ -41,14 +41,22 @@ def check_same(old_row, new_row, old_fields, new_fields=None):
|
|||
raise ValueError(f"Fields '{old_field}' and '{new_field}' differs for rows '{old_row}' and '{new_row}'")
|
||||
return True
|
||||
|
||||
def get_user_id_for_org_id(org_id):
|
||||
query = """SELECT auth_user.id FROM auth_user
|
||||
INNER JOIN seminar_osoby ON seminar_osoby.user_id = auth_user.id
|
||||
INNER JOIN seminar_organizator ON seminar_organizator.osoba_id = seminar_osoby.id
|
||||
WHERE seminar_organizator.id = %s """
|
||||
|
||||
newcur.execute(query,(org_id,))
|
||||
return newcur.fetchone()['id']
|
||||
|
||||
|
||||
|
||||
|
||||
def check_skola():
|
||||
old_query = "SELECT * FROM seminar_skoly ORDER BY id"
|
||||
new_query = old_query
|
||||
|
||||
old_res, new_res = execute_simple(old_query,new_query)
|
||||
|
||||
old_res, new_res = execute_simple(old_query)
|
||||
res = zip(old_res,new_res)
|
||||
|
||||
for o,n in res:
|
||||
|
@ -148,10 +156,93 @@ def check_organizator():
|
|||
if o.organizuje_do_roku != n.organizuje_do.year:
|
||||
raise ValueError(f'Not matching organizuje_do for org id={o.id}: old {o.organizuje_do_roku}, new {n.organizuje_do}')
|
||||
|
||||
def check_rocnik():
|
||||
old_query = "SELECT * FROM seminar_rocniky ORDER BY id"
|
||||
|
||||
old_res, new_res = execute_simple(old_query)
|
||||
res = zip(old_res,new_res)
|
||||
|
||||
for o,n in res:
|
||||
check_same(o,n,['id','prvni_rok', 'rocnik', 'exportovat'])
|
||||
|
||||
def check_cislo():
|
||||
old_query = "SELECT * FROM seminar_cisla ORDER BY id"
|
||||
|
||||
old_res, new_res = execute_simple(old_query)
|
||||
res = zip(old_res,new_res)
|
||||
|
||||
for o,n in res:
|
||||
check_same(o,n, ['id','rocnik_id','cislo', 'datum_vydani','datum_deadline','verejne','poznamka','pdf'],
|
||||
['id','rocnik_id','poradi','datum_vydani','datum_deadline','verejne','poznamka','pdf'])
|
||||
|
||||
def check_priloha_reseni():
|
||||
old_query = "SELECT * FROM seminar_priloha_reseni"
|
||||
|
||||
old_res, new_res = execute_simple(old_query)
|
||||
res = zip(old_res,new_res)
|
||||
|
||||
for o,n in res:
|
||||
check_same(o,n, ['id','reseni_id', 'timestamp', 'soubor', 'poznamka'],
|
||||
['id','reseni_id', 'vytvoreno', 'soubor', 'poznamka'])
|
||||
|
||||
def check_soustredeni():
|
||||
old_query = "SELECT * FROM seminar_soustredeni ORDER BY id"
|
||||
|
||||
old_res, new_res = execute_simple(old_query)
|
||||
res = zip(old_res,new_res)
|
||||
|
||||
for o,n in res:
|
||||
check_same(o,n,['id','rocnik_id','datum_zacatku','datum_konce','verejne','misto','text','typ','exportovat'])
|
||||
#Kontrola ucasnici, organizatori v samostatnych funkcich
|
||||
|
||||
def check_soustredeni_ucastnici():
|
||||
old_query = "SELECT * FROM seminar_soustredeni_ucastnici ORDER BY id"
|
||||
|
||||
old_res, new_res = execute_simple(old_query)
|
||||
res = zip(old_res,new_res)
|
||||
|
||||
for o,n in res:
|
||||
check_same(o,n,['id','resitel_id','soustredeni_id','poznamka'])
|
||||
|
||||
def check_soustredeni_organizatori():
|
||||
old_query = "SELECT * FROM seminar_soustredeni_organizatori ORDER BY id"
|
||||
|
||||
old_res, new_res = execute_simple(old_query)
|
||||
res = zip(old_res,new_res)
|
||||
|
||||
for o,n in res:
|
||||
check_same(o,n,['id','organizator_id','soustredeni_id','poznamka'])
|
||||
|
||||
def check_nastaveni():
|
||||
old_query = "SELECT * FROM seminar_nastaveni ORDER BY id"
|
||||
|
||||
old_res, new_res = execute_simple(old_query)
|
||||
res = zip(old_res,new_res)
|
||||
|
||||
for o,n in res:
|
||||
check_same(o,n,['id','aktualni_cislo_id'])
|
||||
|
||||
def check_novinky():
|
||||
old_query = "SELECT * FROM seminar_novinky ORDER BY id"
|
||||
|
||||
old_res, new_res = execute_simple(old_query)
|
||||
res = zip(old_res,new_res)
|
||||
|
||||
for o,n in res:
|
||||
check_same(o,n,['id','datum','text','obrazek','zverejneno'])
|
||||
if get_user_id_for_org_id(n['autor_id']) != o['autor_id']:
|
||||
raise ValueError("Nesedi autori u novinek")
|
||||
|
||||
|
||||
check_skola()
|
||||
check_resitel()
|
||||
check_reseni()
|
||||
check_organizator()
|
||||
|
||||
check_rocnik()
|
||||
check_cislo()
|
||||
check_priloha_reseni()
|
||||
check_soustredeni()
|
||||
check_soustredeni_ucastnici()
|
||||
check_soustredeni_organizatori()
|
||||
check_nastaveni()
|
||||
check_novinky()
|
||||
|
|
Loading…
Reference in a new issue