From 79002512706b331643036b1a30cc02e15a61ede7 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Tom=C3=A1=C5=A1=20Domes?= Date: Thu, 23 May 2019 22:21:13 +0200 Subject: [PATCH 1/7] testutils: oprava par chyb, pokracovani debugovani na Anetine notebooku --- seminar/testutils.py | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/seminar/testutils.py b/seminar/testutils.py index a0c0e380..017c621a 100644 --- a/seminar/testutils.py +++ b/seminar/testutils.py @@ -77,7 +77,7 @@ 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)) @@ -202,7 +202,7 @@ def create_test_data(size = 6, rnd = None): skoly = gen_skoly() # osoby - osoby = gen_osoby() + osoby = gen_osoby(size) # resitele a organizatori last_rocnik = 25 From 5afa47c18ecf0251a5615d1f1390dbacd207c53b Mon Sep 17 00:00:00 2001 From: Anet Date: Thu, 23 May 2019 22:26:00 +0200 Subject: [PATCH 2/7] testutils: oprava indentace --- seminar/testutils.py | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) diff --git a/seminar/testutils.py b/seminar/testutils.py index a0c0e380..8d03e52f 100644 --- a/seminar/testutils.py +++ b/seminar/testutils.py @@ -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 From 4b0eb89e00336fdfe5f009005f715689cffc611b Mon Sep 17 00:00:00 2001 From: Anet Date: Thu, 23 May 2019 22:52:08 +0200 Subject: [PATCH 3/7] testutils: zdebugovane nejvetsi chyby, hazi uz jen runtime errory --- seminar/testutils.py | 38 +++++++++++++++++++------------------- 1 file changed, 19 insertions(+), 19 deletions(-) diff --git a/seminar/testutils.py b/seminar/testutils.py index 0eb04cf9..82688e37 100644 --- a/seminar/testutils.py +++ b/seminar/testutils.py @@ -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'] @@ -83,7 +83,7 @@ def gen_skoly(): 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,14 +93,14 @@ 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) @@ -108,15 +108,15 @@ def gen_organizatori(osoby, last_rocnik): pusobnost = rnd.randint(1, last_rocnik) od = 1993 + last_rocnik - 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á", @@ -202,15 +202,15 @@ def create_test_data(size = 6, rnd = None): skoly = gen_skoly() # osoby - osoby = gen_osoby(size) + 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() @@ -240,7 +240,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: From 8b2593b926304acbb3cea98f944eb35f7966b669 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Tom=C3=A1=C5=A1=20Domes?= Date: Thu, 23 May 2019 22:54:07 +0200 Subject: [PATCH 4/7] =?UTF-8?q?testutils.py=20-=20drobn=C3=A9=20opravy?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- seminar/testutils.py | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/seminar/testutils.py b/seminar/testutils.py index 017c621a..e39a2d01 100644 --- a/seminar/testutils.py +++ b/seminar/testutils.py @@ -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) @@ -97,7 +97,7 @@ def gen_prijemci(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): @@ -106,7 +106,7 @@ def gen_organizatori(osoby, last_rocnik): 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: From cb4bc3d07ec8cc731e7523ff4db844b1d167143a Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Kate=C5=99ina=20=C4=8C=C3=AD=C5=BEkov=C3=A1?= Date: Thu, 23 May 2019 22:54:10 +0200 Subject: [PATCH 5/7] =?UTF-8?q?testutils:=20p=C5=99id=C3=A1n=C3=AD=20komen?= =?UTF-8?q?t=C3=A1=C5=99e?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- seminar/testutils.py | 24 ++++++++++++------------ 1 file changed, 12 insertions(+), 12 deletions(-) diff --git a/seminar/testutils.py b/seminar/testutils.py index a0c0e380..a90cff79 100644 --- a/seminar/testutils.py +++ b/seminar/testutils.py @@ -34,7 +34,7 @@ def gen_osoby(size): 'Unterschiedlich', 'Old York', 'Lancastershire', 'Vóloďháza'] osoby = [] - for i in range(3 * size): + for i in range(3 * size): # 3 je náhodná konstanta, size je použité na víc místech a říká, jak velká asi chceme testovací data pohlavi = rnd.randint(0,1) jmeno = rnd.choice([jmena_m, jmena_f][pohlavi]) prijmeni = rnd.choice([prijmeni_m, prijmeni_f][pohlavi]) @@ -170,7 +170,18 @@ def gen_ulohy_do_cisla(cislo, organizatori, resitele, slovnik_cisel, size): cislo_body=slovnik_cisel[cislo], reseni=res, problem=p) return +def gen_soustredeni(): + # TODO: vice soustredeni a k nim nahodne podmnoziny organizatoru a ucastniku + sous = Soustredeni.objects.create(rocnik=Rocnik.objects.first(), verejne_db=True, + misto=u'Někde', datum_zacatku=datetime.date(2000, 11, 23), + datum_konce=datetime.date(2000, 11, 27)) + for res in rnd.sample(resitele, 6): + Soustredeni_Ucastnici.objects.create(resitel=res, soustredeni=sous) + sous.save() + + nastaveni = Nastaveni.objects.create(aktualni_rocnik = Rocnik.objects.last(), + aktualni_cislo = Cislo.objects.all()[1]) @transaction.atomic def create_test_data(size = 6, rnd = None): @@ -299,16 +310,5 @@ def create_test_data(size = 6, rnd = None): # TODO: nahodne nagenerovat problemum reseni a prilohy reseni, hodnoceni - # TODO: vice soustredeni a k nim nahodne podmnoziny organizatoru a ucastniku - sous = Soustredeni.objects.create(rocnik=Rocnik.objects.first(), verejne_db=True, - misto=u'Někde', datum_zacatku=datetime.date(2000, 11, 23), - datum_konce=datetime.date(2000, 11, 27)) - - for res in rnd.sample(resitele, 6): - Soustredeni_Ucastnici.objects.create(resitel=res, soustredeni=sous) - sous.save() - - nastaveni = Nastaveni.objects.create(aktualni_rocnik = Rocnik.objects.last(), - aktualni_cislo = Cislo.objects.all()[1]) From 252c2ce679425d5e220f861a6f13da608cb7434b Mon Sep 17 00:00:00 2001 From: LEdoian Date: Thu, 23 May 2019 23:09:47 +0200 Subject: [PATCH 6/7] =?UTF-8?q?Smaz=C3=A1n=C3=AD=20star=C3=BDch=20model?= =?UTF-8?q?=C5=AF=20a=20field=C5=AF?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../0055_smazat_nemigrovane_zastarale_veci.py | 56 +++++++++++++++++++ 1 file changed, 56 insertions(+) create mode 100644 seminar/migrations/0055_smazat_nemigrovane_zastarale_veci.py diff --git a/seminar/migrations/0055_smazat_nemigrovane_zastarale_veci.py b/seminar/migrations/0055_smazat_nemigrovane_zastarale_veci.py new file mode 100644 index 00000000..3f3e7dbe --- /dev/null +++ b/seminar/migrations/0055_smazat_nemigrovane_zastarale_veci.py @@ -0,0 +1,56 @@ +# -*- coding: utf-8 -*- +# Generated by Django 1.11.20 on 2019-05-23 20:16 +from __future__ import unicode_literals + +from django.db import migrations, models + + +class Migration(migrations.Migration): + + dependencies = [ + ('seminar', '0054_problem_to_uloha_tema_clanek'), + ] + + operations = [ + migrations.RemoveField( + model_name='prispevek', + name='problem', + ), + migrations.RemoveField( + model_name='prispevek', + name='reseni', + ), + migrations.DeleteModel( + name='ProblemNavrh', + ), + migrations.DeleteModel( + name='ProblemZadany', + ), + migrations.RemoveField( + model_name='cislo', + name='faze', + ), + migrations.RemoveField( + model_name='konfera', + name='popis', + ), + migrations.RemoveField( + model_name='konfera', + name='prispevek', + ), + migrations.RemoveField( + model_name='problem', + name='import_dakos_id', + ), + migrations.RemoveField( + model_name='resitel', + name='import_mamoper_id', + ), + migrations.RemoveField( + model_name='skola', + name='import_dakos_id', + ), + migrations.DeleteModel( + name='Prispevek', + ), + ] From 6082e4ff26061d6bf432a785e1f5027d644eacf0 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Kate=C5=99ina=20=C4=8C=C3=AD=C5=BEkov=C3=A1?= Date: Thu, 23 May 2019 23:19:05 +0200 Subject: [PATCH 7/7] =?UTF-8?q?testdata:=20koment=C3=A1=C5=99?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- seminar/testutils.py | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/seminar/testutils.py b/seminar/testutils.py index 4c815e49..73233c22 100644 --- a/seminar/testutils.py +++ b/seminar/testutils.py @@ -114,7 +114,7 @@ def gen_organizatori(rnd, osoby, last_rocnik): organizatori.append(Organizator.objects.create(osoba=os, user=rnd.choice(users), organizuje_od=od, organizuje_do=do)) - return organizatri + return organizatori def gen_ulohy_do_cisla(rnd, cislo, organizatori, resitele, slovnik_cisel, size): '''cislo = cislo cisla v rocniku, nikoli objekt Cislo ''' @@ -139,7 +139,7 @@ def gen_ulohy_do_cisla(rnd, cislo, organizatori, resitele, slovnik_cisel, size): if cislo >= 3: for pi in range(1, ((size + 1) // 2) + 1): - poc_op = rnd.randint(1, 4) + poc_op = rnd.randint(1, 4) #počet opravovatelů poc_oboru = rnd.randint(1, 2) p = Uloha.objects.create( nazev=" ".join([rnd.choice(jaka), rnd.choice(co)]),