|
|
@ -13,7 +13,7 @@ from django.contrib.sites.models import Site |
|
|
|
|
|
|
|
User = django.contrib.auth.get_user_model() |
|
|
|
|
|
|
|
def gen_osoby(size): |
|
|
|
def gen_osoby(rnd, size): |
|
|
|
jmena_m = ['Aleš', 'Tomáš', 'Martin', 'Jakub', 'Petr', 'Lukáš', 'Cyril', 'Pavel Karel'] |
|
|
|
jmena_f = ['Eva', 'Karolína', 'Zuzana', 'Sylvie', 'Iva', 'Jana', 'Marie', |
|
|
|
'Marta Iva', 'Shu Shan'] |
|
|
@ -61,7 +61,7 @@ def gen_osoby(size): |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
def gen_skoly(): |
|
|
|
def gen_skoly(): #TODO někdy to přepsat, aby jich bylo více |
|
|
|
skoly = [] |
|
|
|
prvnizs = Skola.objects.create(mesto='Praha', stat='CZ', psc='101 00', |
|
|
|
ulice='Krátká 5', nazev='První ZŠ', je_zs=True, je_ss=False) |
|
|
@ -77,13 +77,13 @@ def gen_skoly(): |
|
|
|
skoly.append(Skola.objects.create(mesto='Humenné', stat='SK', psc='012 34', |
|
|
|
ulice='Pltká 1', nazev='Sredná škuola', je_zs=False, je_ss=True)) |
|
|
|
#FIXME pridat kontaktni osobu alespon nekde |
|
|
|
skoly.append(zlinska = Skola.objects.create(mesto = 'Zlín', stat='CZ', psc='76001', |
|
|
|
skoly.append(Skola.objects.create(mesto = 'Zlín', stat='CZ', psc='76001', |
|
|
|
ulice='náměstí T.G. Masaryka 2734-9', |
|
|
|
nazev='Gymnázium a Střední jazyková škola s právem SJZ', |
|
|
|
kratky_nazev="GaSJŠspSJZ", je_zs=True, je_ss=True)) |
|
|
|
return skoly |
|
|
|
|
|
|
|
def gen_resitele(osoby, skoly): |
|
|
|
def gen_resitele(rnd, osoby, skoly): |
|
|
|
resitele = [] |
|
|
|
for os in osoby: |
|
|
|
rand = rnd.randint(0, 8) |
|
|
@ -93,30 +93,30 @@ def gen_resitele(osoby, skoly): |
|
|
|
zasilat=rnd.choice(Resitel.ZASILAT_CHOICES))) |
|
|
|
return resitele |
|
|
|
|
|
|
|
def gen_prijemci(osoby, kolik=10): |
|
|
|
def gen_prijemci(rnd, osoby, kolik=10): |
|
|
|
prijemci = [] |
|
|
|
for i in range(kolik): |
|
|
|
rand_os = rnd.choice(osoby) |
|
|
|
prijemci.add(Prijemce.objects.create(osoba=rand_os)) |
|
|
|
prijemci.append(Prijemce.objects.create(osoba=rand_os)) |
|
|
|
return prijemci |
|
|
|
|
|
|
|
def gen_organizatori(osoby, last_rocnik): |
|
|
|
def gen_organizatori(rnd, osoby, last_rocnik): |
|
|
|
organizatori = [] |
|
|
|
for os in osoby: |
|
|
|
rand = rnd.randint(0, 8) |
|
|
|
if (rand % 8 == 0): |
|
|
|
pusobnost = rnd.randint(1, last_rocnik) |
|
|
|
od = 1993 + last_rocnik - pusobnost |
|
|
|
od = 1993 + pusobnost |
|
|
|
do = od + rnd.randint(1, 6) |
|
|
|
# aktualni organizatori jeste nemaji vyplnene organizuje_do |
|
|
|
#if do > datetime.datetime.now().year: |
|
|
|
# do = None |
|
|
|
#organizatori.append(Organizator.objects.create(osoba=os, |
|
|
|
# user=rnd.choice(users), |
|
|
|
# organizuje_od=od, organizuje_do=do)) |
|
|
|
return organizatori |
|
|
|
|
|
|
|
def gen_ulohy_do_cisla(cislo, organizatori, resitele, slovnik_cisel, size): |
|
|
|
#aktualni organizatori jeste nemaji vyplnene organizuje_do |
|
|
|
if do > datetime.datetime.now().year: |
|
|
|
do = None |
|
|
|
organizatori.append(Organizator.objects.create(osoba=os, |
|
|
|
user=rnd.choice(users), |
|
|
|
organizuje_od=od, organizuje_do=do)) |
|
|
|
return organizatri |
|
|
|
|
|
|
|
def gen_ulohy_do_cisla(rnd, cislo, organizatori, resitele, slovnik_cisel, size): |
|
|
|
'''cislo = cislo cisla v rocniku, nikoli objekt Cislo ''' |
|
|
|
# ulohy resene v ci |
|
|
|
jaka = ["Šachová", "Černá", "Větrná", "Dlouhá", "Křehká", "Rychlá", |
|
|
@ -163,11 +163,11 @@ def gen_ulohy_do_cisla(cislo, organizatori, resitele, slovnik_cisel, size): |
|
|
|
poc_resitel = rnd.randint(1, 3) |
|
|
|
res_sel = rnd.sample(resitele, min(poc_reseni, len(resitele) - 2)) |
|
|
|
for resitel in res_sel: |
|
|
|
res = Reseni.objects.create(problem = p, |
|
|
|
resitele=[resitel], |
|
|
|
forma=rnd.choice(Reseni.FORMA_CHOICES)) |
|
|
|
hod = Hodnoceni.objects.create(body=rnd.randint(0, p.max_body), |
|
|
|
cislo_body=slovnik_cisel[cislo], reseni=res, problem=p) |
|
|
|
res = Reseni.objects.create(problem = p, |
|
|
|
resitele=[resitel], |
|
|
|
forma=rnd.choice(Reseni.FORMA_CHOICES)) |
|
|
|
hod = Hodnoceni.objects.create(body=rnd.randint(0, p.max_body), |
|
|
|
cislo_body=slovnik_cisel[cislo], reseni=res, problem=p) |
|
|
|
return |
|
|
|
|
|
|
|
def gen_soustredeni(): |
|
|
@ -213,15 +213,15 @@ def create_test_data(size = 6, rnd = None): |
|
|
|
skoly = gen_skoly() |
|
|
|
|
|
|
|
# osoby |
|
|
|
osoby = gen_osoby() |
|
|
|
osoby = gen_osoby(rnd, size) |
|
|
|
|
|
|
|
# resitele a organizatori |
|
|
|
last_rocnik = 25 |
|
|
|
resitele = gen_resitele(osoby) |
|
|
|
organizatori = gen_organizatori(osoby) |
|
|
|
resitele = gen_resitele(rnd, osoby, skoly) |
|
|
|
organizatori = gen_organizatori(rnd, osoby, last_rocnik) |
|
|
|
|
|
|
|
# prijemci |
|
|
|
prijemci = gen_prijemci() |
|
|
|
prijemci = gen_prijemci(rnd) |
|
|
|
|
|
|
|
zlinska.kontaktni_osoba=rnd.choice(osoby) |
|
|
|
zlinska.save() |
|
|
@ -251,7 +251,7 @@ def create_test_data(size = 6, rnd = None): |
|
|
|
slovnik_cisel[ci] = cislo |
|
|
|
|
|
|
|
# generovani uloh |
|
|
|
gen_ulohy_do_cisla(ci, organizatori, resitele, size) |
|
|
|
gen_ulohy_do_cisla(rnd, ci, organizatori, resitele, slovnik_cisel, size) |
|
|
|
|
|
|
|
# generovani temat |
|
|
|
if ci <= 3: |
|
|
|