Merge branch 'data_migrations' of gimli.ms.mff.cuni.cz:/akce/mam/git/mamweb into data_migrations
This commit is contained in:
commit
d14acdd77e
2 changed files with 73 additions and 17 deletions
56
seminar/migrations/0055_smazat_nemigrovane_zastarale_veci.py
Normal file
56
seminar/migrations/0055_smazat_nemigrovane_zastarale_veci.py
Normal file
|
@ -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',
|
||||
),
|
||||
]
|
|
@ -34,7 +34,7 @@ def gen_osoby(rnd, 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])
|
||||
|
@ -61,7 +61,7 @@ def gen_osoby(rnd, 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)
|
||||
|
@ -106,7 +106,7 @@ def gen_organizatori(rnd, osoby, last_rocnik, users):
|
|||
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:
|
||||
|
@ -138,7 +138,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)]),
|
||||
|
@ -162,8 +162,8 @@ def gen_ulohy_do_cisla(rnd, cislo, organizatori, resitele, slovnik_cisel, size):
|
|||
poc_resitel = rnd.randint(1, 3)
|
||||
# vybereme nahodny vzorek resitelu o delce poctu reseni
|
||||
# (nebo skoro vsechny resitele, pokud jich je mene nez pocet reseni)
|
||||
res_sel = rnd.sample(resitele, min(poc_reseni, len(resitele) - 2))
|
||||
for resitel in res_sel:
|
||||
res_vyber = rnd.sample(resitele, min(poc_reseni, len(resitele) - 2))
|
||||
for resitel in res_vyber:
|
||||
res = Reseni.objects.create(problem = p,
|
||||
resitele=[resitel],
|
||||
forma=rnd.choice(Reseni.FORMA_CHOICES))
|
||||
|
@ -171,7 +171,18 @@ def gen_ulohy_do_cisla(rnd, 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):
|
||||
|
@ -300,16 +311,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])
|
||||
|
||||
|
||||
|
|
Loading…
Reference in a new issue