From ba546353d864eae5c61afa709f143287bb64cb72 Mon Sep 17 00:00:00 2001 From: Pavel 'LEdoian' Turinsky Date: Wed, 30 Oct 2019 23:26:59 +0100 Subject: [PATCH 1/4] =?UTF-8?q?Prvn=C3=AD=20pokus=20o=20squash.?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../0001_squashed_0067_auto_20190814_0805.py | 2236 +++++++++++++++++ 1 file changed, 2236 insertions(+) create mode 100644 seminar/migrations/0001_squashed_0067_auto_20190814_0805.py diff --git a/seminar/migrations/0001_squashed_0067_auto_20190814_0805.py b/seminar/migrations/0001_squashed_0067_auto_20190814_0805.py new file mode 100644 index 00000000..f1f046af --- /dev/null +++ b/seminar/migrations/0001_squashed_0067_auto_20190814_0805.py @@ -0,0 +1,2236 @@ +# Generated by Django 2.2.6 on 2019-10-30 20:20 + +from django.conf import settings +from django.db import migrations, models +import django.db.migrations.operations.special +import django.db.models.deletion +import django.utils.timezone +import django_countries.fields +import imagekit.models.fields +import seminar.models +import taggit.managers + + +# Functions from the following migrations need manual copying. +# Move them and any dependencies into this file, then update the +# RunPython operations to refer to the local versions: + +# seminar.migrations.0051_resitel_to_osoba + +def resitel_to_osoba(apps,schema_editor): + Resitel = apps.get_model('seminar','Resitel') + Osoba = apps.get_model('seminar','Osoba') + for r in Resitel.objects.all(): + o = Osoba() + o.datum_narozeni = r.datum_narozeni + o.datum_registrace = r.datum_prihlaseni + o.datum_souhlasu_udaje = r.datum_souhlasu_udaje + o.datum_souhlasu_zasilani = r.datum_souhlasu_zasilani + o.email = r.email + o.jmeno = r.jmeno + o.mesto = r.mesto + o.pohlavi_muz = r.pohlavi_muz + o.prijmeni = r.prijmeni + o.psc = r.psc + o.stat = r.stat + o.telefon = r.telefon + o.ulice = r.ulice + o.user = r.user + if o.user: + u = o.user + if u.first_name: + if not o.jmeno: + o.jmeno = u.first_name + u.first_name = 'Použij osobu!' + elif o.jmeno == u.first_name: + u.first_name = 'Použij osobu!' + else: + raise ValueError('jmeno a first_name rozdílné: "{}" vs. "{}"'.format(o.jmeno, u.first_name)) + if u.last_name: + if not o.prijmeni: + o.prijmeni = u.last_name + u.last_name = 'Použij osobu!' + elif o.prijmeni == u.last_name: + u.last_name = 'Použij osobu!' + else: + raise ValueError('prijmeni a last_name rozdílné: "{}" vs. "{}"'.format(o.prijmeni, u.last_name)) + if u.email: + if not o.email: + o.email = u.email + u.email = 'Použij osobu!' + elif o.email == u.email: + u.email = 'Použij osobu!' + else: + raise ValueError('o.email a u.email rozdílné: "{}" vs. "{}"'.format(o.email, u.email)) + u.save() + + + o.save() + r.osoba = o + r.save() + +def osoba_to_resitel(apps, schema_editor): + Resitel = apps.get_model('seminar','Resitel') + Osoba = apps.get_model('seminar','Osoba') + for r in Resitel.objects.all(): + o = r.osoba + r.datum_narozeni = o.datum_narozeni + r.datum_prihlaseni = o.datum_registrace + r.datum_souhlasu_udaje = o.datum_souhlasu_udaje + r.datum_souhlasu_zasilani = o.datum_souhlasu_zasilani + r.email = o.email + r.jmeno = o.jmeno + r.mesto = o.mesto + r.pohlavi_muz = o.pohlavi_muz + r.prijmeni = o.prijmeni + r.psc = o.psc + r.stat = o.stat + r.telefon = o.telefon + r.ulice = o.ulice + r.user = o.user + r.save() + o.delete() + + +# seminar.migrations.0052_user_to_organizator + +def spoj_k_organizatorum_osoby(apps, scema_editor): + Organizator = apps.get_model('seminar', 'Organizator') + Resitel = apps.get_model('seminar', 'Resitel') + Osoba = apps.get_model('seminar', 'Osoba') + for org in Organizator.objects.all(): + + # Spárování organizátora s osobou + user = org.user + resitele = Resitel.objects.filter(user=user) + if resitele.count() != 0: + osoba = resitele.first().osoba + else: + osoba = Osoba(user=user) + + # Přesun informací z usera do osoby + # pro řešitele již v minule migraci + osoba.jmeno = user.first_name + osoba.prijmeni = user.last_name + osoba.email = user.email + user.jmeno = "Použij osobu!" + user.prijmeni = "Použij osobu!" + user.email = "Použij osobu!" + user.save() + + # Přesun informací z organizátora do jeho osoby + osoba.prezdivka = org.prezdivka if org.prezdivka is not None else '' + osoba.foto = org.foto + + # Všechno uložit + osoba.save() + org.osoba = osoba + org.save() + +def fix_problem(apps, schema_editor): + Problem = apps.get_model('seminar', 'Problem') + Organizator = apps.get_model('seminar', 'Organizator') + for pr in Problem.objects.all(): + if pr.autor_old is not None: + pr.autor = Organizator.objects.filter(osoba__user=pr.autor_old).first() + else: + pr.autor = None + if pr.opravovatel is not None: + pr.opravovatele.add(Organizator.objects.filter(osoba__user=pr.opravovatel).first()) + pr.save() + +def fix_pohadka(apps, schema_editor): + Pohadka = apps.get_model('seminar', 'Pohadka') + Organizator = apps.get_model('seminar', 'Organizator') + for poh in Pohadka.objects.all(): + if poh.autor_old is not None: + poh.autor = Organizator.objects.filter(osoba__user=poh.autor_old).first() + else: + poh.autor = None + poh.save() + +def fix_novinka(apps, schema_editor): + Novinky = apps.get_model('seminar', 'Novinky') + Organizator = apps.get_model('seminar', 'Organizator') + for nov in Novinky.objects.all(): + nov.autor = Organizator.objects.filter(osoba__user=nov.autor_old).first() + nov.save() + +# seminar.migrations.0053_organizator_organizuje_od_do + +def rok_to_datetime(apps,schema_editor): + Organizator = apps.get_model('seminar','Organizator') + for o in Organizator.objects.all(): + rok = o.organizuje_od_roku + if rok: + o.organizuje_od = dt.datetime(rok,1,1) + rok = o.organizuje_do_roku + if rok: + o.organizuje_do = dt.datetime(rok,12,31) + o.save() + +def datetime_to_rok(apps,schema_editor): + Organizator = apps.get_model('seminar','Organizator') + for o in Organizator.objects.all(): + o.organizuje_od_roku = o.organizuje_od.year + o.organizuje_do_roku = o.organizuje_do.year + o.save() + +# seminar.migrations.0056_vrcholy_pro_rocniky_a_cisla + +def generuj_RocnikNody_a_CisloNody(apps,schema_editor): + Rocnik = apps.get_model('seminar', 'Rocnik') + RocnikNode = apps.get_model('seminar', 'RocnikNode') + Cislo = apps.get_model('seminar', 'Cislo') + CisloNode = apps.get_model('seminar', 'CisloNode') + + last_rn = None # last_* slouží k navázání následníků + for r in Rocnik.objects.all(): + rn = RocnikNode.objects.create(rocnik=r) + rn.save() + rn.root = rn + rn.save() + if last_rn: + last_rn.succ = rn + last_rn.save() + last_rn = rn + + last_cn = None + for c in Cislo.objects.filter(rocnik=r): + cn = CisloNode.objects.create(cislo=c, root=rn) + cn.save() + if last_cn: # Jsme něčí následník + last_cn.succ = cn + last_cn.save() + else: # Jsme první v řadě, takže se musíme přidat jako first_child RočníkNodu + rn.first_child = cn + rn.save() + last_cn = cn + +# seminar.migrations.0057_reseni_to_reseni_hodnoceni + +def reseni_to_Reseni(apps, schema_editor): + Reseni = apps.get_model('seminar','Reseni') + Reseni_Resitele = apps.get_model('seminar','Reseni_Resitele') + Hodnoceni = apps.get_model('seminar','Hodnoceni') + + for r in Reseni.objects.all(): + rr = Reseni_Resitele.objects.create(resitele = r.resitel, reseni=r) + if r.body == None: + print("!!!!!!!!!!!!!!!") + print(r.id,r) + print("!!!!!!!!!!!!!!!") + else: + h = Hodnoceni.objects.create( + body=r.body, + cislo_body = r.cislo_body, + problem = r.problem_old, + reseni = r) + +# seminar.migrations.0058_problem_to_uloha_tema_clanek + +def poskladej_strom(apps, rodic, *texty): + Text = apps.get_model('seminar', 'Text') + TextNode = apps.get_model('seminar', 'TextNode') + if not rodic: + raise ValueError("Rodič musí být definovaný") + + uz_ma_deti = False + tn = None + for txt in texty: + if not txt: + continue + # Přidej do stromu: + textobj = Text.objects.create(na_web = txt) + textobj.save() + textnode = TextNode.objects.create(text = textobj) + textnode.save() + if not uz_ma_deti: + rodic.first_child = textnode + rodic.save() + tn = rodic.first_child + uz_ma_deti = True + else: + tn.succ = textnode + tn.save() + tn = tn.succ + +def uloha_to_Uloha(apps,schema_editor): + Problem = apps.get_model('seminar', 'Problem') + Uloha = apps.get_model('seminar', 'Uloha') + Text = apps.get_model('seminar', 'Text') + UlohaZadaniNode = apps.get_model('seminar', 'UlohaZadaniNode') + UlohaVzorakNode = apps.get_model('seminar', 'UlohaVzorakNode') + TextNode = apps.get_model('seminar', 'TextNode') + + ulohy = Problem.objects.filter(typ = 'uloha') + for uold in ulohy: + unew = Uloha.objects.create( + problem_ptr = uold, + # Zakomentované fieldy by se už měly nacházet v příslušném problému + #nazev = uold.nazev, + #stav = uold.stav, + #zamereni = uold.zamereni, + #poznamka = uold.poznamka, + #autor = uold.autor, + #kod = uold.kod, + cislo_zadani = uold.cislo_zadani_old, + cislo_reseni = uold.cislo_reseni_old, + max_body = uold.body, + #vytvoreno = uold.vytvoreno, + ) +# unew.opravovatele.add(*uold.opravovatele.all()) + unew.save() + + # Nody: + zadani_node = UlohaZadaniNode.objects.create(uloha = unew) + poskladej_strom(apps, zadani_node, uold.text_zadani) + zadani_node.save() + vzorak_node = UlohaVzorakNode.objects.create(uloha = unew) + poskladej_strom(apps, vzorak_node, uold.text_reseni) + vzorak_node.save() + +def konfery_rucne(apps, schema_editor): + # Tohle dělat nebudu, máme aktuálně celou jednu. Ale "Errors should never pass silently" + Problem = apps.get_model('seminar', 'Problem') + pocet_konfer = Problem.objects.filter(typ = 'konfera').count() + if pocet_konfer > 0: + raise NotImplementedError("Zkonvertuj {} konfer na objekt Konfera ručně, prosím".format(pocet_konfer)) + +def clanek_to_Clanek(apps,schema_editor): + Problem = apps.get_model('seminar', 'Problem') + Clanek = apps.get_model('seminar', 'Clanek') + ClanekNode = apps.get_model('seminar', 'ClanekNode') + Text = apps.get_model('seminar', 'Text') + TextNode = apps.get_model('seminar', 'TextNode') + + clanky = Problem.objects.filter(Q(typ='org-clanek') | Q(typ='res-clanek')) + for cl in clanky: + # Vybereme vhodné číslo pro článek z čísla zadání a čísla řešení: + if cl.cislo_zadani_old is None: + cislo = cl.cislo_reseni_old + elif cl.cislo_reseni_old is None: + cislo = cl.cislo_zadani_old + elif cl.cislo_reseni_old == cl.cislo_zadani_old: + cislo = cl.cislo_zadani_old + else: + raise ValueError("Různá čísla zadání a řešení u článku! (Článek: {})".format(cl.nazev)) + + clnew = Clanek.objects.create( + problem_ptr = cl, + # Problém by nemělo být potřeba upravovat + cislo = cislo, + # Body ignorujeme, protože už jsou v hodnocení + ) + clnew.save() + + # Aktuálně nemáme v modelu informaci o tom, jestli je to org-článek + # nebo řešitelský článek. Aby se neztratila informace, poznamenám to do + # poznámky. + cl.poznamka += "\nTyp:\t{}".format(cl.typ) + cl.save() + + # Vyrobíme nody: + clnode = ClanekNode(clanek = clnew) + poskladej_strom(apps, clnode, cl.text_zadani, cl.text_reseni) + clnode.save() + +def tema_to_Tema(apps, schema_editor): + Problem = apps.get_model('seminar', 'Problem') + Tema = apps.get_model('seminar', 'Tema') + TemaVCisleNode = apps.get_model('seminar', 'TemaVCisleNode') + Text = apps.get_model('seminar', 'Text') + TextNode = apps.get_model('seminar', 'TextNode') + + temata = Problem.objects.filter(Q(typ = 'tema') | Q(typ='serial')) + for t in temata: + # Vymyslíme správně ročník: + if t.cislo_zadani_old is None and t.cislo_reseni_old is None: + rocnik = None + elif t.cislo_zadani_old is None: + rocnik = t.cislo_reseni_old.rocnik + elif t.cislo_reseni_old is None: + rocnik = t.cislo_zadani_old.rocnik + elif t.cislo_reseni_old.rocnik == t.cislo_zadani_old.rocnik: + rocnik = t.cislo_zadani_old.rocnik + else: + raise ValueError("Nelze mít téma přes více ročníků! (Téma: {}".format(t.nazev)) + + tnew = Tema.objects.create( + problem_ptr = t, + tema_typ = t.typ, + rocnik = rocnik, + ) + tnew.save() + + # Nody: + tnode = TemaVCisleNode(tema = tnew) + poskladej_strom(apps, tnode, t.text_zadani, t.text_reseni) + tnode.save() + +# seminar.migrations.0059_vytvorit_pohadkanode + +def vytvor_pohadkanode(apps, schema_editor): + Pohadka = apps.get_model('seminar', 'Pohadka') + PohadkaNode = apps.get_model('seminar', 'PohadkaNode') + Text = apps.get_model('seminar', 'Text') + TextNode = apps.get_model('seminar', 'TextNode') + + for p in Pohadka.objects.all(): + t = Text.objects.create(na_web = p.text) + t.save() + tn = TextNode.objects.create(text = t) + tn.save() + pn = PohadkaNode.objects.create(pohadka = p, first_child = tn) + pn.save() + +# seminar.migrations.0060_spoj_stromy + +def pridej_potomka(rodic, potomek): + # Daný vrchol bude posledním potomkem rodiče + uz_ma_deti = False + posledni = None + + # Přidávaný potomek by neměl mít následovníka -- přidáváme potomka, ne podles. + if potomek.succ: + raise ValueError("Potomek má následovníka, to je velmi podezřelé!") + + # Najdeme aktuálně posledního potomka: + if rodic.first_child: + uz_ma_deti = True + posledni = rodic.first_child + while posledni.succ: + posledni = posledni.succ + + # Nastavíme kořen: + potomek.root = rodic.root + potomek.save() + + # Připojíme vrchol: + if uz_ma_deti: + posledni.succ = potomek + posledni.save() + else: + rodic.first_child = potomek + rodic.save() + +def pokacej_les(apps, schema_editor): + # Teď je potřeba všechny TreeNody příslušející k zadaným problémům připojit + # do hlavního stromu + # Tohle je jednoduchá verze: nejdřív témátka a seriály, pak úložky a pohádky, + # pak články a konfery, pak vzoráky, všechno setříděné podle kódu (FIXME?) + + # Kopírování je častým zdrojem chyb! + Cislo = apps.get_model('seminar', 'Cislo') + Tema = apps.get_model('seminar', 'Tema') + Konfera = apps.get_model('seminar', 'Konfera') + Clanek = apps.get_model('seminar', 'Clanek') + Uloha = apps.get_model('seminar', 'Uloha') + Problem = apps.get_model('seminar', 'Problem') + Pohadka = apps.get_model('seminar', 'Pohadka') + + for c in Cislo.objects.all().reverse(): + cnode = c.cislonode + + # Témata a seriály: + relevantni_temata = Tema.objects.filter(Q(cislo_zadani_old = c) | Q(cislo_reseni_old = c)).order_by('kod') + # Téma dáme do prvního čísla, kde se vyskytne + for t in relevantni_temata: + tnode = t.temavcislenode + if t.cislo_zadani_old and t.cislo_reseni_old: + assert(t.cislo_zadani_old <= t.cislo_reseni_old) + if t.cislo_reseni_old == c: + # Už by mělo být přidané do čísla zadání + continue + else: + # Patří sem (buď je to jediné číslo, nebo je to číslo zadání) + pridej_potomka(cnode, tnode) + + # Úložky (zadání) a pohádky + for u in Uloha.objects.filter(cislo_zadani = c).order_by('kod'): + unode = u.ulohazadaninode + pohadky_pred = Pohadka.objects.filter(uloha_old = u.problem_ptr, pred = True) + pohadky_po = Pohadka.objects.filter(uloha_old = u.problem_ptr, pred = False) + for p in pohadky_pred: + pnode = p.pohadkanode + pridej_potomka(cnode, pnode) + pridej_potomka(cnode, unode) + for p in pohadky_po: + pnode = p.pohadkanode + pridej_potomka(cnode, pnode) + + # Pohádky, které nejsou u úlohy jsou špatně: + if Pohadka.objects.exclude(uloha_old__typ='uloha').count(): + raise ValueError("Existuje pohádka, která není u úlohy") + + # Články + for cl in Clanek.objects.filter(cislo = c).order_by('kod'): + clnode = cl.claneknode + pridej_potomka(cnode, clnode) + + # Konfery + for k in Konfera.objects.all(): + knode = k.konferanode + if k.reseni and knode.root is None: + # Takováhle konfera nejspíš neexistuje + raise NotImplementedError("Konfery neumím zapojit do stromu") + + # Vzoráky + for u in Uloha.objects.filter(cislo_reseni = c).order_by('kod'): + unode = u.ulohavzoraknode + pridej_potomka(cnode, unode) + +# seminar.migrations.0065_treenode_polymorphic_ctype + +def vyrob_treenodum_ctypes(apps, schema_editor): + # Kód zkopírovaný z dokumentace: https://django-polymorphic.readthedocs.io/en/stable/migrating.html + # XXX: Nevím, jestli se tohle náhodou nemělo spustit na všech childech (jen/i) + TreeNode = apps.get_model('seminar', 'TreeNode') + ContentType = apps.get_model('contenttypes', 'ContentType') + + new_ct = ContentType.objects.get_for_model(TreeNode) + TreeNode.objects.filter(polymorphic_ctype__isnull=True).update(polymorphic_ctype=new_ct) + +# seminar.migrations.0066_problem_polymorphic_ctype + +def vyrob_problemum_ctypes(apps, schema_editor): + # Kód zkopírovaný z dokumentace: https://django-polymorphic.readthedocs.io/en/stable/migrating.html + # XXX: Nevím, jestli se tohle náhodou nemělo spustit na všech childech (jen/i) + Problem = apps.get_model('seminar', 'Problem') + ContentType = apps.get_model('contenttypes', 'ContentType') + + new_ct = ContentType.objects.get_for_model(Problem) + Problem.objects.filter(polymorphic_ctype__isnull=True).update(polymorphic_ctype=new_ct) + + +class Migration(migrations.Migration): + + replaces = [('seminar', '0001_initial'), ('seminar', '0002_add_body_views'), ('seminar', '0003_add_skola_zs_ss'), ('seminar', '0004_add_old_dakos_id'), ('seminar', '0005_alter_problem_autor'), ('seminar', '0006_problem_add_timestamp'), ('seminar', '0007_problem_zamereni'), ('seminar', '0008_reseni_forma'), ('seminar', '0009_rename_imported_IDs'), ('seminar', '0010_alter_rok_maturity'), ('seminar', '0011_alter_timestamp_def'), ('seminar', '0012_remove_soustredeni_ucastnici'), ('seminar', '0013_soustredeni_ucastnici_through_model'), ('seminar', '0014_uprava_poznamek'), ('seminar', '0015_soustredeni_text'), ('seminar', '0016_texty_problemu'), ('seminar', '0017_texty_problemu_minor'), ('seminar', '0018_problemnavrh_problemzadany'), ('seminar', '0019_rocnik_ciselne'), ('seminar', '0020_indexy_a_razeni'), ('seminar', '0021_cislo_verejna_vysledkovka'), ('seminar', '0022_decimal_body'), ('seminar', '0023_add_novinky'), ('seminar', '0024_add_organizator'), ('seminar', '0025_zmena_cesty_nahravani_obrazku'), ('seminar', '0026_soustredeni_typ'), ('seminar', '0027_export_flag_a_typ_akce'), ('seminar', '0028_add_body_celkem_views'), ('seminar', '0029_fix_body_celkem_views'), ('seminar', '0030_add_vysledky'), ('seminar', '0031_cislo_pdf'), ('seminar', '0032_cislo_pdf_blank_typos'), ('seminar', '0033_organizator_studuje_popisek'), ('seminar', '0034_reseni_forma_default_email'), ('seminar', '0035_django_imagekit'), ('seminar', '0036_add_org_to_soustredeni'), ('seminar', '0037_prispevek'), ('seminar', '0038_change_meta_prispevek'), ('seminar', '0039_pohadka'), ('seminar', '0040_pohadka_nepovinny_autor'), ('seminar', '0041_konfery'), ('seminar', '0042_cislo_faze'), ('seminar', '0043_uprava_faze'), ('seminar', '0044_uprava_faze'), ('seminar', '0045_cislo_pridani_faze_nahrano'), ('seminar', '0042_auto_20161005_0847'), ('seminar', '0046_merge'), ('seminar', '0047_auto_20170120_2118'), ('seminar', '0048_add_cislo_datum_deadline_soustredeni'), ('seminar', '0049_auto_20190430_2354'), ('seminar', '0050_auto_20190510_2228'), ('seminar', '0051_resitel_to_osoba'), ('seminar', '0052_user_to_organizator'), ('seminar', '0053_organizator_organizuje_od_do'), ('seminar', '0055_smazat_nemigrovane_zastarale_veci'), ('seminar', '0056_vrcholy_pro_rocniky_a_cisla'), ('seminar', '0057_reseni_to_reseni_hodnoceni'), ('seminar', '0058_problem_to_uloha_tema_clanek'), ('seminar', '0059_vytvorit_pohadkanode'), ('seminar', '0060_spoj_stromy'), ('seminar', '0061_kill_frankenstein'), ('seminar', '0062_redukce_modelu_pohadky'), ('seminar', '0063_procisteni_migraci'), ('seminar', '0064_auto_20190610_2358'), ('seminar', '0065_treenode_polymorphic_ctype'), ('seminar', '0066_problem_polymorphic_ctype'), ('seminar', '0067_auto_20190814_0805')] + + initial = True + + dependencies = [ + ('contenttypes', '0002_remove_content_type_name'), + ('taggit', '0001_initial'), + migrations.swappable_dependency(settings.AUTH_USER_MODEL), + ] + + operations = [ + migrations.CreateModel( + name='VysledkyKCislu', + fields=[ + ('dummy_id', models.CharField(db_column='id', max_length=32, primary_key=True, serialize=False, verbose_name='dummy ID pro view')), + ('body', models.IntegerField(db_column='body', verbose_name='body za číslo')), + ('body_celkem', models.IntegerField(db_column='body_celkem', verbose_name='body celkem do čísla')), + ], + options={ + 'abstract': False, + 'db_table': 'seminar_body_k_cislu', + 'managed': False, + }, + ), + migrations.CreateModel( + name='VysledkyZaCislo', + fields=[ + ('dummy_id', models.CharField(db_column='id', max_length=32, primary_key=True, serialize=False, verbose_name='dummy ID pro view')), + ('body', models.IntegerField(db_column='body', verbose_name='body za číslo')), + ], + options={ + 'abstract': False, + 'db_table': 'seminar_body_za_cislo', + 'managed': False, + }, + ), + migrations.CreateModel( + name='Cislo', + fields=[ + ('id', models.AutoField(primary_key=True, serialize=False)), + ('cislo', models.CharField(help_text='Většinou jen "1", vyjímečně "7-8", lexikograficky určije pořadí v ročníku!', max_length=32, verbose_name='název čísla')), + ('datum_vydani', models.DateField(blank=True, help_text='Datum vydání finální verze', null=True, verbose_name='datum vydání')), + ('datum_deadline', models.DateField(blank=True, help_text='Datum pro příjem řešení úloh zadaných v tomto čísle', null=True, verbose_name='datum deadline')), + ('verejne_db', models.BooleanField(db_column='verejne', default=False, verbose_name='číslo zveřejněno')), + ], + options={ + 'ordering': ['rocnik__rocnik', 'cislo'], + 'db_table': 'seminar_cisla', + 'verbose_name': 'Číslo', + 'verbose_name_plural': 'Čísla', + }, + ), + migrations.CreateModel( + name='Problem', + fields=[ + ('id', models.AutoField(primary_key=True, serialize=False)), + ('nazev', models.CharField(max_length=256, verbose_name='název')), + ('typ', models.CharField(choices=[(b'uloha', 'Úloha'), (b'tema', 'Téma'), (b'serial', 'Seriál'), (b'org-clanek', 'Organizátorský článek'), (b'res-clanek', 'Řesitelský článek')], default=b'uloha', max_length=32, verbose_name='typ problému')), + ('stav', models.CharField(choices=[(b'navrh', 'Návrh'), (b'zadany', 'Zadaný'), (b'smazany', 'Smazaný')], default=b'navrh', max_length=32, verbose_name='stav problému')), + ('text_problemu_org', models.TextField(blank=True, verbose_name='organizátorský (neveřejný) text')), + ('text_problemu', models.TextField(blank=True, verbose_name='veřejný text zadání a řešení')), + ('kod', models.CharField(blank=True, default=b'', help_text='Číslo/kód úlohy v čísle nebo kód tématu/článku/seriálu v ročníku', max_length=32, verbose_name='lokální kód')), + ('body', models.IntegerField(blank=True, null=True, verbose_name='maximum bodů')), + ('autor', models.ForeignKey(on_delete=django.db.models.deletion.CASCADE, related_name='autor_uloh', to=settings.AUTH_USER_MODEL, verbose_name='autor problému')), + ('cislo_reseni', models.ForeignKey(blank=True, help_text='Číslo s řešením úlohy, jen pro úlohy', null=True, on_delete=django.db.models.deletion.CASCADE, related_name='resene_problemy', to='seminar.Cislo', verbose_name='číslo řešení')), + ('cislo_zadani', models.ForeignKey(blank=True, null=True, on_delete=django.db.models.deletion.CASCADE, related_name='zadane_problemy', to='seminar.Cislo', verbose_name='číslo zadání')), + ('opravovatel', models.ForeignKey(blank=True, null=True, on_delete=django.db.models.deletion.CASCADE, related_name='opravovatel_uloh', to=settings.AUTH_USER_MODEL, verbose_name='opravovatel')), + ], + options={ + 'db_table': 'seminar_problemy', + 'verbose_name': 'Problém', + 'verbose_name_plural': 'Problémy', + }, + ), + migrations.CreateModel( + name='Resitel', + fields=[ + ('id', models.AutoField(primary_key=True, serialize=False)), + ('jmeno', models.CharField(max_length=256, verbose_name='jméno')), + ('prijmeni', models.CharField(max_length=256, verbose_name='příjmení')), + ('pohlavi_muz', models.BooleanField(default=False, verbose_name='pohlaví (muž)')), + ('rok_maturity', models.IntegerField(verbose_name='rok maturity')), + ('email', models.EmailField(blank=True, default=b'', max_length=256, verbose_name='e-mail')), + ('telefon', models.CharField(blank=True, default=b'', max_length=256, verbose_name='telefon')), + ('datum_narozeni', models.DateField(blank=True, null=True, verbose_name='datum narození')), + ('datum_souhlasu_udaje', models.DateField(blank=True, help_text='Datum souhlasu se zpracováním osobních údajů', null=True, verbose_name='datum souhlasu (údaje)')), + ('datum_souhlasu_zasilani', models.DateField(blank=True, help_text='Datum souhlasu se zasíláním MFF materiálů', null=True, verbose_name='datum souhlasu (spam)')), + ('datum_prihlaseni', models.DateField(default=django.utils.timezone.now, verbose_name='datum přihlášení')), + ('zasilat', models.CharField(choices=[(b'domu', 'Domů'), (b'do_skoly', 'Do školy'), (b'nikam', 'Nikam')], default=b'domu', max_length=32, verbose_name='kam zasílat')), + ('ulice', models.CharField(blank=True, default=b'', max_length=256, verbose_name='ulice')), + ('mesto', models.CharField(blank=True, default=b'', max_length=256, verbose_name='město')), + ('psc', models.CharField(blank=True, default=b'', max_length=32, verbose_name='PSČ')), + ('stat', django_countries.fields.CountryField(default=b'CZ', help_text='ISO 3166-1 kód země velkými písmeny (CZ, SK, ...)', max_length=2, verbose_name='stát')), + ('poznamka', models.TextField(blank=True, help_text='Neveřejná poznámka k řešiteli (plain text)', verbose_name='neveřejná poznámka')), + ], + options={ + 'ordering': ['prijmeni', 'jmeno'], + 'db_table': 'seminar_resitele', + 'verbose_name': 'Řešitel', + 'verbose_name_plural': 'Řešitelé', + }, + ), + migrations.CreateModel( + name='Rocnik', + fields=[ + ('id', models.AutoField(primary_key=True, serialize=False)), + ('prvni_rok', models.IntegerField(verbose_name='první rok')), + ('rocnik', models.CharField(max_length=16, verbose_name='číslo ročníku')), + ], + options={ + 'ordering': ['rocnik'], + 'db_table': 'seminar_rocniky', + 'verbose_name': 'Ročník', + 'verbose_name_plural': 'Ročníky', + }, + ), + migrations.CreateModel( + name='Skola', + fields=[ + ('id', models.AutoField(primary_key=True, serialize=False)), + ('aesop_id', models.CharField(blank=True, default=b'', help_text='Aesopi ID typu "izo:..." nebo "aesop:..."', max_length=32, verbose_name='Aesop ID')), + ('izo', models.CharField(blank=True, help_text='IZO školy (jen české školy)', max_length=32, verbose_name='IZO')), + ('nazev', models.CharField(help_text='Celý název školy', max_length=256, verbose_name='název')), + ('kratky_nazev', models.CharField(blank=True, help_text=b'Zkr\xc3\xa1cen\xc3\xbd n\xc3\xa1zev pro zobrazen\xc3\xad ve v\xc3\xbdsledkovce', max_length=256, verbose_name='zkrácený název')), + ('ulice', models.CharField(max_length=256, verbose_name='ulice')), + ('mesto', models.CharField(max_length=256, verbose_name='město')), + ('psc', models.CharField(max_length=32, verbose_name='PSČ')), + ('stat', django_countries.fields.CountryField(default=b'CZ', help_text='ISO 3166-1 kód zeme velkými písmeny (CZ, SK, ...)', max_length=2, verbose_name='stát')), + ('poznamka', models.TextField(blank=True, help_text='Neveřejná poznámka ke škole (plain text)', verbose_name='neveřejná poznámka')), + ], + options={ + 'db_table': 'seminar_skoly', + 'verbose_name': 'Škola', + 'verbose_name_plural': 'Školy', + }, + ), + migrations.CreateModel( + name='Soustredeni', + fields=[ + ('id', models.AutoField(primary_key=True, serialize=False)), + ('datum_zacatku', models.DateField(blank=True, help_text='První den soustředění', null=True, verbose_name='datum začátku')), + ('datum_konce', models.DateField(blank=True, help_text='Poslední den soustředění', null=True, verbose_name='datum konce')), + ('verejne_db', models.BooleanField(db_column='verejne', default=False, verbose_name='soustředění zveřejněno')), + ('misto', models.CharField(blank=True, default=b'', help_text='Místo (název obce, volitelně též objektu', max_length=256, verbose_name='místo soustředění')), + ('rocnik', models.ForeignKey(on_delete=django.db.models.deletion.CASCADE, related_name='soustredeni', to='seminar.Rocnik', verbose_name='ročník')), + ('ucastnici', models.ManyToManyField(db_table='seminar_soustredeni_ucastnici', help_text='Seznam účastníků soustředění', to='seminar.Resitel', verbose_name='účastníci soustředění')), + ], + options={ + 'ordering': ['rocnik__rocnik', 'datum_zacatku'], + 'db_table': 'seminar_soustredeni', + 'verbose_name': 'Soustředění', + 'verbose_name_plural': 'Soustředění', + }, + ), + migrations.AddField( + model_name='resitel', + name='skola', + field=models.ForeignKey(blank=True, null=True, on_delete=django.db.models.deletion.CASCADE, to='seminar.Skola', verbose_name='škola'), + ), + migrations.AddField( + model_name='resitel', + name='user', + field=models.OneToOneField(blank=True, null=True, on_delete=django.db.models.deletion.CASCADE, to=settings.AUTH_USER_MODEL, verbose_name='uživatel'), + ), + migrations.CreateModel( + name='Reseni', + fields=[ + ('id', models.AutoField(primary_key=True, serialize=False)), + ('body', models.IntegerField(blank=True, null=True, verbose_name='body')), + ('timestamp', models.DateTimeField(auto_now=True, verbose_name='vytvořeno')), + ('poznamka', models.TextField(blank=True, help_text='Neveřejná poznámka k řešení (plain text)', verbose_name='neveřejná poznámka')), + ('cislo_body', models.ForeignKey(blank=True, null=True, on_delete=django.db.models.deletion.CASCADE, related_name='bodovana_reseni', to='seminar.Cislo', verbose_name='číslo pro body')), + ('problem', models.ForeignKey(on_delete=django.db.models.deletion.CASCADE, related_name='reseni', to='seminar.Problem', verbose_name='problém')), + ('resitel', models.ForeignKey(on_delete=django.db.models.deletion.CASCADE, related_name='reseni', to='seminar.Resitel', verbose_name='řešitel')), + ], + options={ + 'ordering': ['problem', 'resitel'], + 'db_table': 'seminar_reseni', + 'verbose_name': 'Řešení', + 'verbose_name_plural': 'Řešení', + }, + ), + migrations.CreateModel( + name='PrilohaReseni', + fields=[ + ('id', models.AutoField(primary_key=True, serialize=False)), + ('timestamp', models.DateTimeField(auto_now=True, verbose_name='vytvořeno')), + ('soubor', models.FileField(upload_to=seminar.models.generate_filename, verbose_name='soubor')), + ('poznamka', models.TextField(blank=True, help_text='Neveřejná poznámka k příloze řešení (plain text), např. o původu', verbose_name='neveřejná poznámka')), + ('reseni', models.ForeignKey(on_delete=django.db.models.deletion.CASCADE, related_name='prilohy', to='seminar.Reseni', verbose_name='řešení')), + ], + options={ + 'ordering': ['reseni', 'timestamp'], + 'db_table': 'seminar_priloha_reseni', + 'verbose_name': 'Příloha řešení', + 'verbose_name_plural': 'Přílohy řešení', + }, + ), + migrations.CreateModel( + name='Nastaveni', + fields=[ + ('id', models.AutoField(auto_created=True, primary_key=True, serialize=False, verbose_name='ID')), + ('aktualni_cislo', models.ForeignKey(on_delete=django.db.models.deletion.CASCADE, to='seminar.Cislo', verbose_name='poslední vydané číslo')), + ('aktualni_rocnik', models.ForeignKey(on_delete=django.db.models.deletion.CASCADE, to='seminar.Rocnik', verbose_name='aktuální ročník')), + ], + options={ + 'db_table': 'seminar_nastaveni', + 'verbose_name': 'Nastavení semináře', + }, + ), + migrations.AddField( + model_name='cislo', + name='rocnik', + field=models.ForeignKey(on_delete=django.db.models.deletion.CASCADE, related_name='cisla', to='seminar.Rocnik', verbose_name='ročník'), + ), + migrations.RunSQL( + sql="\ncreate view seminar_body_za_cislo as\n select\n sr.cislo_body_id || '-' || sr.resitel_id as id,\n sr.cislo_body_id as cislo_id,\n sr.resitel_id as resitel_id,\n sum(sr.body) as body\n from seminar_reseni as sr\n group by sr.cislo_body_id, sr.resitel_id\n order by body desc;\n\ncreate view seminar_body_k_cislu as\n select\n akt_c.id || '-' || min_bzc.resitel_id as id,\n akt_c.id as cislo_id,\n min_bzc.resitel_id as resitel_id,\n max(akt_bzc.body) as body,\n sum(min_bzc.body) as body_celkem\n from ((seminar_cisla as akt_c\n inner join seminar_cisla as min_c on min_c.rocnik_id = akt_c.rocnik_id and akt_c.cislo >= min_c.cislo)\n inner join seminar_body_za_cislo as min_bzc on min_c.id = min_bzc.cislo_id)\n left outer join seminar_body_za_cislo as akt_bzc on akt_bzc.cislo_id = akt_c.id and akt_bzc.resitel_id = min_bzc.resitel_id \n group by akt_c.id, min_bzc.resitel_id, akt_bzc.resitel_id\n order by body_celkem desc;\n", + reverse_sql='\ndrop view seminar_body_k_cislu;\ndrop view seminar_body_za_cislo;\n', + ), + migrations.AlterField( + model_name='reseni', + name='poznamka', + field=models.TextField(blank=True, help_text='Neveřejná poznámka k řešení (plain text, editace v detailu řešení)', verbose_name='neveřejná poznámka'), + ), + migrations.AddField( + model_name='skola', + name='je_ss', + field=models.BooleanField(default=True, verbose_name='střední stupeň'), + ), + migrations.AddField( + model_name='skola', + name='je_zs', + field=models.BooleanField(default=True, verbose_name='základní stupeň'), + ), + migrations.AlterField( + model_name='problem', + name='autor', + field=models.ForeignKey(blank=True, null=True, on_delete=django.db.models.deletion.CASCADE, related_name='autor_uloh', to=settings.AUTH_USER_MODEL, verbose_name='autor problému'), + ), + migrations.AddField( + model_name='problem', + name='zamereni', + field=taggit.managers.TaggableManager(blank=True, help_text=b'Zam\xc4\x9b\xc5\x99en\xc3\xad M/F/I/O probl\xc3\xa9mu, p\xc5\x99\xc3\xadp. dal\xc5\xa1\xc3\xad tagy', through='taggit.TaggedItem', to='taggit.Tag', verbose_name='zaměření'), + ), + migrations.AddField( + model_name='reseni', + name='forma', + field=models.CharField(choices=[(b'papir', 'Papírové řešení'), (b'email', 'Emailem'), (b'upload', 'Upload přes web')], default=b'papir', max_length=16, verbose_name='forma řešení'), + ), + migrations.AddField( + model_name='resitel', + name='import_mamoper_id', + field=models.CharField(blank=True, default=b'', help_text='MAMOPER.MM_RIESITELIA.ID z DAKOS importu, jen historický význam', max_length=32, verbose_name='importované MM_RIESITELIA.ID'), + ), + migrations.AddField( + model_name='skola', + name='import_dakos_id', + field=models.CharField(blank=True, default=b'', help_text='DKSROOT.V_SKOLA.ID z DAKOS importu, jen historický význam', max_length=32, verbose_name='importované DKSROOT.V_SKOLA.ID'), + ), + migrations.AlterField( + model_name='resitel', + name='rok_maturity', + field=models.IntegerField(blank=True, null=True, verbose_name='rok maturity'), + ), + migrations.AlterField( + model_name='prilohareseni', + name='timestamp', + field=models.DateTimeField(blank=True, default=django.utils.timezone.now, editable=False, verbose_name='vytvořeno'), + ), + migrations.AddField( + model_name='problem', + name='import_dakos_id', + field=models.CharField(blank=True, default=b'', help_text='ID z importu z DAKOSU s prefixem podle původu: "AZAD:xxx (MAMOPER.MM_AZAD), ""DOZ:xxx" (MAMOPER.MM_DOZ), "ZAD:rocnik.cislo.uloha.typ" (MAMOPER.MM_ZADANIA), "ULOHA:xxx" (MAMOPER.MM_ULOHY)', max_length=32, verbose_name='importované ID s typem'), + ), + migrations.AddField( + model_name='problem', + name='timestamp', + field=models.DateTimeField(blank=True, default=django.utils.timezone.now, editable=False, verbose_name='vytvořeno'), + ), + migrations.AlterField( + model_name='reseni', + name='timestamp', + field=models.DateTimeField(blank=True, default=django.utils.timezone.now, editable=False, verbose_name='vytvořeno'), + ), + migrations.RemoveField( + model_name='soustredeni', + name='ucastnici', + ), + migrations.CreateModel( + name='Soustredeni_Ucastnici', + fields=[ + ('id', models.AutoField(primary_key=True, serialize=False)), + ('poznamka', models.TextField(blank=True, help_text='Neveřejná poznámka k účasti (plain text)', verbose_name='neveřejná poznámka')), + ('resitel', models.ForeignKey(on_delete=django.db.models.deletion.CASCADE, to='seminar.Resitel', verbose_name='řešitel')), + ('soustredeni', models.ForeignKey(on_delete=django.db.models.deletion.CASCADE, to='seminar.Soustredeni', verbose_name='soustředění')), + ], + options={ + 'ordering': ['soustredeni', 'resitel'], + 'db_table': 'seminar_soustredeni_ucastnici', + 'verbose_name': 'Účast na soustředění', + 'verbose_name_plural': 'Účasti na soustředění', + }, + ), + migrations.AddField( + model_name='soustredeni', + name='ucastnici', + field=models.ManyToManyField(help_text='Seznam účastníků soustředění', through='seminar.Soustredeni_Ucastnici', to='seminar.Resitel', verbose_name='účastníci soustředění'), + ), + migrations.AlterModelOptions( + name='problem', + options={'ordering': ['nazev'], 'verbose_name': 'Problém', 'verbose_name_plural': 'Problémy'}, + ), + migrations.AlterModelOptions( + name='reseni', + options={'ordering': ['problem_id', 'resitel_id'], 'verbose_name': 'Řešení', 'verbose_name_plural': 'Řešení'}, + ), + migrations.AlterModelOptions( + name='skola', + options={'ordering': ['mesto', 'nazev'], 'verbose_name': 'Škola', 'verbose_name_plural': 'Školy'}, + ), + migrations.AddField( + model_name='cislo', + name='poznamka', + field=models.TextField(blank=True, help_text='Neveřejná poznámka k číslu (plain text)', verbose_name='neveřejná poznámka'), + ), + migrations.AlterField( + model_name='reseni', + name='poznamka', + field=models.TextField(blank=True, help_text='Neveřejná poznámka k řešení (plain text)', verbose_name='neveřejná poznámka'), + ), + migrations.AddField( + model_name='soustredeni', + name='text', + field=models.TextField(blank=True, default=b'', verbose_name='text k soustředění (HTML)'), + ), + migrations.RenameField( + model_name='problem', + old_name='text_problemu_org', + new_name='text_org', + ), + migrations.AlterField( + model_name='problem', + name='text_org', + field=models.TextField(blank=True, verbose_name='neveřejné zadání a organizátorské a poznámky'), + ), + migrations.RenameField( + model_name='problem', + old_name='text_problemu', + new_name='text_zadani', + ), + migrations.AlterField( + model_name='problem', + name='text_org', + field=models.TextField(blank=True, help_text='Neveřejný návrh úlohy, návrh řešení, text zadání, poznámky ...', verbose_name='org poznámky (HTML)'), + ), + migrations.AlterField( + model_name='problem', + name='text_zadani', + field=models.TextField(blank=True, help_text='Veřejný text zadání (HTML)', verbose_name='veřejné zadání (HTML)'), + ), + migrations.AddField( + model_name='problem', + name='text_reseni', + field=models.TextField(blank=True, help_text='Veřejný text řešení (HTML, u témat i příspěvky a komentáře)', verbose_name='veřejné řešení (HTML)'), + ), + migrations.CreateModel( + name='ProblemNavrh', + fields=[ + ], + options={ + 'verbose_name': 'Problém (návrh)', + 'proxy': True, + 'verbose_name_plural': 'Problémy (návrhy)', + }, + bases=('seminar.problem',), + ), + migrations.CreateModel( + name='ProblemZadany', + fields=[ + ], + options={ + 'verbose_name': 'Problém (zadaný)', + 'proxy': True, + 'verbose_name_plural': 'Problémy (zadané)', + }, + bases=('seminar.problem',), + ), + migrations.AddField( + model_name='rocnik', + name='rocnik_n', + field=models.IntegerField(default=0, verbose_name='číslo ročníku'), + preserve_default=False, + ), + migrations.RunSQL( + sql='update seminar_rocniky set rocnik_n = cast (rocnik as integer)', + ), + migrations.RemoveField( + model_name='rocnik', + name='rocnik', + ), + migrations.RenameField( + model_name='rocnik', + old_name='rocnik_n', + new_name='rocnik', + ), + migrations.AlterModelOptions( + name='cislo', + options={'ordering': ['-rocnik__rocnik', '-cislo'], 'verbose_name': 'Číslo', 'verbose_name_plural': 'Čísla'}, + ), + migrations.AlterModelOptions( + name='reseni', + options={'ordering': ['problem_id', 'resitel__prijmeni', 'resitel__jmeno'], 'verbose_name': 'Řešení', 'verbose_name_plural': 'Řešení'}, + ), + migrations.AlterModelOptions( + name='rocnik', + options={'ordering': ['-rocnik'], 'verbose_name': 'Ročník', 'verbose_name_plural': 'Ročníky'}, + ), + migrations.AlterField( + model_name='cislo', + name='cislo', + field=models.CharField(db_index=True, help_text='Většinou jen "1", vyjímečně "7-8", lexikograficky určije pořadí v ročníku!', max_length=32, verbose_name='název čísla'), + ), + migrations.AlterField( + model_name='rocnik', + name='prvni_rok', + field=models.IntegerField(db_index=True, unique=True, verbose_name='první rok'), + ), + migrations.AlterField( + model_name='rocnik', + name='rocnik', + field=models.IntegerField(db_index=True, unique=True, verbose_name='číslo ročníku'), + ), + migrations.AddField( + model_name='cislo', + name='verejna_vysledkovka', + field=models.BooleanField(default=False, help_text='Je-li false u veřejného čísla, není výsledkovka zatím veřejná.', verbose_name='zveřejněna výsledkovka'), + ), + migrations.RunSQL( + sql='\ndrop view seminar_body_k_cislu;\ndrop view seminar_body_za_cislo;\n', + ), + migrations.AlterField( + model_name='problem', + name='body', + field=models.DecimalField(blank=True, decimal_places=1, max_digits=8, null=True, verbose_name='maximum bodů'), + ), + migrations.AlterField( + model_name='reseni', + name='body', + field=models.DecimalField(blank=True, decimal_places=1, max_digits=8, null=True, verbose_name='body'), + ), + migrations.RunSQL( + sql="\ncreate view seminar_body_za_cislo as\n select\n sr.cislo_body_id || '-' || sr.resitel_id as id,\n sr.cislo_body_id as cislo_id,\n sr.resitel_id as resitel_id,\n sum(sr.body) as body\n from seminar_reseni as sr\n group by sr.cislo_body_id, sr.resitel_id\n order by body desc;\n\ncreate view seminar_body_k_cislu as\n select\n akt_c.id || '-' || min_bzc.resitel_id as id,\n akt_c.id as cislo_id,\n min_bzc.resitel_id as resitel_id,\n max(akt_bzc.body) as body,\n sum(min_bzc.body) as body_celkem\n from ((seminar_cisla as akt_c\n inner join seminar_cisla as min_c on min_c.rocnik_id = akt_c.rocnik_id and akt_c.cislo >= min_c.cislo)\n inner join seminar_body_za_cislo as min_bzc on min_c.id = min_bzc.cislo_id)\n left outer join seminar_body_za_cislo as akt_bzc on akt_bzc.cislo_id = akt_c.id and akt_bzc.resitel_id = min_bzc.resitel_id \n group by akt_c.id, min_bzc.resitel_id, akt_bzc.resitel_id\n order by body_celkem desc;\n", + ), + migrations.CreateModel( + name='Novinky', + fields=[ + ('id', models.AutoField(auto_created=True, primary_key=True, serialize=False, verbose_name='ID')), + ('datum', models.DateField(auto_now_add=True)), + ('text', models.TextField(blank=True, null=True, verbose_name=b'Text novinky')), + ('obrazek', models.ImageField(blank=True, null=True, upload_to=b'image_novinky/%Y/%m/%d/', verbose_name=b'Obr\xc3\xa1zek')), + ('zverejneno', models.BooleanField(default=False, verbose_name=b'Zve\xc5\x99ejn\xc4\x9bno')), + ('autor', models.ForeignKey(on_delete=django.db.models.deletion.CASCADE, to=settings.AUTH_USER_MODEL, verbose_name=b'Autor novinky')), + ], + options={ + 'verbose_name': 'Novinka', + 'verbose_name_plural': 'Novinky', + }, + ), + migrations.CreateModel( + name='Organizator', + fields=[ + ('id', models.AutoField(auto_created=True, primary_key=True, serialize=False, verbose_name='ID')), + ('prezdivka', models.CharField(blank=True, max_length=32, null=True, verbose_name=b'P\xc5\x99ezd\xc3\xadvka')), + ('organizuje_od_roku', models.IntegerField(blank=True, null=True, verbose_name=b'Organizuje od roku')), + ('organizuje_do_roku', models.IntegerField(blank=True, null=True, verbose_name=b'Organizuje do roku')), + ('studuje', models.CharField(blank=True, max_length=256, null=True, verbose_name=b'Studuje')), + ('strucny_popis_organizatora', models.TextField(blank=True, null=True, verbose_name=b'Stru\xc4\x8dn\xc3\xbd popis organiz\xc3\xa1tora')), + ('foto', models.ImageField(blank=True, help_text=b'Vlo\xc5\xbe fotografii organiz\xc3\xa1tora o libovon\xc3\xa9 velikosti', null=True, upload_to=b'image_organizatori/velke/%Y/', verbose_name=b'Fotografie organiz\xc3\xa1tora')), + ('foto_male', models.ImageField(blank=True, editable=False, null=True, upload_to=b'image_organizatori/male/%Y/')), + ('user', models.OneToOneField(help_text=b'Vyber \xc3\xba\xc4\x8det sp\xc5\x99a\xc5\xbeen\xc3\xbd s organiz\xc3\xa1torem.', on_delete=django.db.models.deletion.CASCADE, to=settings.AUTH_USER_MODEL, verbose_name=b'Osoba')), + ], + options={ + 'verbose_name': 'Organizátor', + 'verbose_name_plural': 'Organizátoři', + }, + ), + migrations.AddField( + model_name='rocnik', + name='exportovat', + field=models.BooleanField(db_column='exportovat', default=False, help_text='Exportuje se jen podle tohoto flagu (ne veřejnosti), a to jen čísla s veřejnou výsledkovkou', verbose_name='export do AESOPa'), + ), + migrations.AddField( + model_name='soustredeni', + name='exportovat', + field=models.BooleanField(db_column='exportovat', default=False, help_text='Exportuje se jen podle tohoto flagu (ne veřejnosti)', verbose_name='export do AESOPa'), + ), + migrations.AddField( + model_name='soustredeni', + name='typ', + field=models.CharField(choices=[(b'jarni', 'Jarní soustředění'), (b'podzimni', 'Podzimní soustředění'), (b'vikend', 'Víkendový sraz')], default=b'podzimni', max_length=16, verbose_name='typ akce'), + ), + migrations.RunSQL( + sql="\ndrop view seminar_body_k_cislu;\ndrop view seminar_body_za_cislo;\n\ncreate view seminar_body_za_cislo as\n select\n seminar_reseni.cislo_body_id || '-' || seminar_reseni.resitel_id as id,\n seminar_reseni.cislo_body_id as cislo_id,\n seminar_reseni.resitel_id as resitel_id,\n seminar_cisla.cislo as cislo,\n seminar_cisla.rocnik_id as rocnik_id,\n seminar_rocniky.rocnik as rocnik,\n seminar_cisla.verejna_vysledkovka as verejna_vysledkovka,\n sum(seminar_reseni.body) as body\n from\n seminar_reseni\n inner join seminar_cisla on seminar_reseni.cislo_body_id = seminar_cisla.id\n inner join seminar_rocniky on seminar_cisla.rocnik_id = seminar_rocniky.id\n group by seminar_reseni.cislo_body_id, seminar_reseni.resitel_id, seminar_cisla.cislo,\n seminar_cisla.rocnik_id, seminar_rocniky.rocnik, seminar_cisla.verejna_vysledkovka\n order by body desc;\n\ncreate view seminar_body_k_cislu_rocnik as\n select\n akt_body.id as id,\n akt_body.cislo_id as cislo_id,\n akt_body.resitel_id as resitel_id,\n akt_body.body as body,\n sum(min_body.body) as body_celkem\n from\n seminar_body_za_cislo as akt_body\n inner join seminar_body_za_cislo as min_body on\n (akt_body.resitel_id = min_body.resitel_id and\n (akt_body.rocnik = min_body.rocnik and akt_body.cislo >= min_body.cislo)\n )\n group by akt_body.id, akt_body.cislo_id, akt_body.resitel_id, akt_body.body\n order by body_celkem desc;\n\ncreate view seminar_body_k_cislu_odjakziva as\n select\n akt_body.id as id,\n akt_body.cislo_id as cislo_id,\n akt_body.resitel_id as resitel_id,\n akt_body.body as body,\n sum(min_body.body) as body_celkem\n from\n seminar_body_za_cislo as akt_body\n inner join seminar_body_za_cislo as min_body on\n (akt_body.resitel_id = min_body.resitel_id and\n ((akt_body.rocnik = min_body.rocnik and akt_body.cislo >= min_body.cislo) or\n (akt_body.rocnik < min_body.rocnik)\n )\n )\n group by akt_body.id, akt_body.cislo_id, akt_body.resitel_id, akt_body.body\n order by body_celkem desc;\n\n", + ), + migrations.RunSQL( + sql="\n\ndrop view seminar_body_k_cislu_rocnik;\ncreate view seminar_body_k_cislu_rocnik as\n select\n seminar_cisla.id || '-' || min_body.resitel_id as id,\n seminar_cisla.id as cislo_id,\n min_body.resitel_id as resitel_id,\n sum(min_body.body) as body\n from\n seminar_cisla\n inner join seminar_body_za_cislo as min_body on\n (min_body.rocnik_id = seminar_cisla.rocnik_id and seminar_cisla.cislo >= min_body.cislo)\n group by seminar_cisla.id, min_body.resitel_id\n order by body desc;\n\ndrop view seminar_body_k_cislu_odjakziva;\ncreate view seminar_body_k_cislu_odjakziva as\n select\n seminar_cisla.id || '-' || min_body.resitel_id as id,\n seminar_cisla.id as cislo_id,\n min_body.resitel_id as resitel_id,\n sum(min_body.body) as body\n from\n seminar_cisla\n inner join seminar_rocniky on\n (seminar_cisla.rocnik_id = seminar_rocniky.id)\n inner join seminar_body_za_cislo as min_body on\n (min_body.rocnik_id = seminar_cisla.rocnik_id and seminar_cisla.cislo >= min_body.cislo) or\n (min_body.rocnik < seminar_rocniky.rocnik)\n group by seminar_cisla.id, min_body.resitel_id\n order by body desc;\n", + ), + migrations.CreateModel( + name='VysledkyCelkemKCislu', + fields=[ + ('dummy_id', models.CharField(db_column=b'id', max_length=32, primary_key=True, serialize=False, verbose_name='dummy ID pro view')), + ('body', models.DecimalField(db_column=b'body', decimal_places=1, max_digits=8, verbose_name='body za číslo')), + ('body_celkem', models.DecimalField(db_column=b'body_celkem', decimal_places=1, max_digits=8, verbose_name='body celkem do čísla včetně minulých ročníků')), + ], + options={ + 'abstract': False, + 'db_table': 'seminar_body_celkem_k_cislu', + 'managed': False, + }, + ), + migrations.CreateModel( + name='VysledkyKCisluOdjakziva', + fields=[ + ('dummy_id', models.CharField(db_column=b'id', max_length=32, primary_key=True, serialize=False, verbose_name='dummy ID pro view')), + ('body', models.DecimalField(db_column=b'body', decimal_places=1, max_digits=8, verbose_name='body za číslo')), + ], + options={ + 'abstract': False, + 'db_table': 'seminar_body_k_cislu_odjakziva', + 'managed': False, + }, + ), + migrations.CreateModel( + name='VysledkyKCisluZaRocnik', + fields=[ + ('dummy_id', models.CharField(db_column=b'id', max_length=32, primary_key=True, serialize=False, verbose_name='dummy ID pro view')), + ('body', models.DecimalField(db_column=b'body', decimal_places=1, max_digits=8, verbose_name='body za číslo')), + ], + options={ + 'abstract': False, + 'db_table': 'seminar_body_k_cislu_rocnik', + 'managed': False, + }, + ), + migrations.AlterField( + model_name='organizator', + name='foto', + field=models.ImageField(blank=True, help_text=b'Vlo\xc5\xbe fotografii organiz\xc3\xa1tora o libovoln\xc3\xa9 velikosti', null=True, upload_to=b'image_organizatori/velke/%Y/', verbose_name=b'Fotografie organiz\xc3\xa1tora'), + ), + migrations.AlterModelOptions( + name='soustredeni', + options={'ordering': ['-rocnik__rocnik', '-datum_zacatku'], 'verbose_name': 'Soustředění', 'verbose_name_plural': 'Soustředění'}, + ), + migrations.AlterField( + model_name='cislo', + name='cislo', + field=models.CharField(db_index=True, help_text='Většinou jen "1", vyjímečně "7-8", lexikograficky určuje pořadí v ročníku!', max_length=32, verbose_name='název čísla'), + ), + migrations.AddField( + model_name='cislo', + name='pdf', + field=models.FileField(blank=True, help_text='Pdf čísla, které si mohou řešitelé stáhnout', null=True, upload_to=seminar.models.cislo_pdf_filename, verbose_name='pdf'), + ), + migrations.AlterField( + model_name='problem', + name='typ', + field=models.CharField(choices=[(b'uloha', 'Úloha'), (b'tema', 'Téma'), (b'serial', 'Seriál'), (b'org-clanek', 'Organizátorský článek'), (b'res-clanek', 'Řešitelský článek')], default=b'uloha', max_length=32, verbose_name='typ problému'), + ), + migrations.AlterField( + model_name='skola', + name='stat', + field=django_countries.fields.CountryField(default=b'CZ', help_text='ISO 3166-1 kód země velkými písmeny (CZ, SK, ...)', max_length=2, verbose_name='stát'), + ), + migrations.AlterField( + model_name='organizator', + name='studuje', + field=models.CharField(blank=True, help_text=b"Nap\xc5\x99. 'Studuje Obecnou fyziku (Bc.), 3. ro\xc4\x8dn\xc3\xadk', 'Vystudovala Diskr\xc3\xa9tn\xc3\xad modely a algoritmy (Mgr.)' nebo 'P\xc5\x99edn\xc3\xa1\xc5\xa1\xc3\xad na MFF'", max_length=256, null=True, verbose_name=b'Studium aj.'), + ), + migrations.AlterField( + model_name='reseni', + name='forma', + field=models.CharField(choices=[(b'papir', 'Papírové řešení'), (b'email', 'Emailem'), (b'upload', 'Upload přes web')], default=b'email', max_length=16, verbose_name='forma řešení'), + ), + migrations.RemoveField( + model_name='organizator', + name='foto_male', + ), + migrations.AlterField( + model_name='organizator', + name='foto', + field=imagekit.models.fields.ProcessedImageField(blank=True, help_text=b'Vlo\xc5\xbe fotografii organiz\xc3\xa1tora o libovoln\xc3\xa9 velikosti', null=True, upload_to=b'image_organizatori/velke/%Y/', verbose_name=b'Fotografie organiz\xc3\xa1tora'), + ), + migrations.CreateModel( + name='Soustredeni_Organizatori', + fields=[ + ('id', models.AutoField(primary_key=True, serialize=False)), + ('poznamka', models.TextField(blank=True, help_text='Neveřejná poznámka k účasti organizátora (plain text)', verbose_name='neveřejná poznámka')), + ('organizator', models.ForeignKey(on_delete=django.db.models.deletion.CASCADE, to='seminar.Organizator', verbose_name='organizátor')), + ('soustredeni', models.ForeignKey(on_delete=django.db.models.deletion.CASCADE, to='seminar.Soustredeni', verbose_name='soustředění')), + ], + options={ + 'ordering': ['soustredeni', 'organizator'], + 'db_table': 'seminar_soustredeni_organizatori', + 'verbose_name': 'Účast organizátorů na soustředění', + 'verbose_name_plural': 'Účasti organizátorů na soustředění', + }, + ), + migrations.AddField( + model_name='soustredeni', + name='organizatori', + field=models.ManyToManyField(help_text='Seznam organizátorů soustředění', through='seminar.Soustredeni_Organizatori', to='seminar.Organizator', verbose_name='Organizátoři soustředění'), + ), + migrations.CreateModel( + name='Prispevek', + fields=[ + ('id', models.AutoField(auto_created=True, primary_key=True, serialize=False, verbose_name='ID')), + ('nazev', models.CharField(max_length=200, verbose_name=b'N\xc3\xa1zev')), + ('text_org', models.TextField(blank=True, null=True, verbose_name=b'Orgovsk\xc3\xbd text')), + ('text_resitel', models.TextField(blank=True, null=True, verbose_name=b'\xc5\x98e\xc5\xa1itelsk\xc3\xbd text')), + ('zverejnit', models.BooleanField(verbose_name=b'Zve\xc5\x99ejnit?')), + ('problem', models.ForeignKey(on_delete=django.db.models.deletion.CASCADE, to='seminar.Problem', verbose_name=b'Probl\xc3\xa9m')), + ('reseni', models.OneToOneField(blank=True, null=True, on_delete=django.db.models.deletion.CASCADE, to='seminar.Reseni', verbose_name=b'\xc5\x98e\xc5\xa1en\xc3\xad')), + ], + options={ + 'abstract': False, + 'verbose_name': 'Příspěvek k problému', + 'verbose_name_plural': 'Příspěvky k problémům', + }, + ), + migrations.CreateModel( + name='Konfera', + fields=[ + ('id', models.AutoField(primary_key=True, serialize=False)), + ('nazev', models.CharField(help_text='Název konfery', max_length=40, verbose_name='název konfery')), + ('popis', models.TextField(blank=True, help_text='Popis konfery k zobrazení na webu', verbose_name='popis konfery')), + ('abstrakt', models.TextField(blank=True, help_text='Abstrakt konfery tak, jak byl uveden ve sborníku', verbose_name='abstrakt')), + ('org_poznamka', models.TextField(blank=True, help_text='Neveřejná poznámka ke konfeře(plain text)', verbose_name='neveřejná poznámka')), + ('typ_prezentace', models.CharField(choices=[(b'veletrh', 'Veletrh (postery)'), (b'prezentace', 'Prezentace (přednáška)')], default=b'veletrh', max_length=16, verbose_name='typ prezentace')), + ('prezentace', models.FileField(help_text='Prezentace nebo fotka posteru', upload_to=seminar.models.generate_filename_konfera, verbose_name='prezentace')), + ('materialy', models.FileField(help_text='Další materiály ke konfeře zabalené do jednoho souboru', upload_to=seminar.models.generate_filename_konfera, verbose_name='materialy')), + ('organizator', models.ForeignKey(null=True, on_delete=django.db.models.deletion.SET_NULL, related_name='konfery', to='seminar.Organizator', verbose_name='organizátor')), + ('soustredeni', models.ForeignKey(null=True, on_delete=django.db.models.deletion.SET_NULL, related_name='konfery', to='seminar.Soustredeni', verbose_name='soustředění')), + ], + options={ + 'db_table': 'seminar_konfera', + 'verbose_name': 'Konfera', + 'verbose_name_plural': 'Konfery', + }, + ), + migrations.CreateModel( + name='Konfery_Ucastnici', + fields=[ + ('id', models.AutoField(primary_key=True, serialize=False)), + ('poznamka', models.TextField(blank=True, help_text='Neveřejná poznámka k účasti (plain text)', verbose_name='neveřejná poznámka')), + ('konfera', models.ForeignKey(on_delete=django.db.models.deletion.PROTECT, to='seminar.Konfera', verbose_name='konfera')), + ('resitel', models.ForeignKey(on_delete=django.db.models.deletion.CASCADE, to='seminar.Resitel', verbose_name='řešitel')), + ], + options={ + 'ordering': ['konfera', 'resitel'], + 'db_table': 'seminar_konfery_ucastnici', + 'verbose_name': 'Účast na konfeře', + 'verbose_name_plural': 'Účasti na konfeře', + }, + ), + migrations.AlterField( + model_name='problem', + name='typ', + field=models.CharField(choices=[(b'uloha', 'Úloha'), (b'tema', 'Téma'), (b'serial', 'Seriál'), (b'konfera', 'Konfera'), (b'org-clanek', 'Organizátorský článek'), (b'res-clanek', 'Řešitelský článek')], default=b'uloha', max_length=32, verbose_name='typ problému'), + ), + migrations.AddField( + model_name='konfera', + name='ucastnici', + field=models.ManyToManyField(help_text='Seznam účastníků konfery', through='seminar.Konfery_Ucastnici', to='seminar.Resitel', verbose_name='účastníci konfery'), + ), + migrations.AlterField( + model_name='konfera', + name='materialy', + field=models.FileField(blank=True, help_text='Další materiály ke konfeře zabalené do jednoho souboru', upload_to=seminar.models.generate_filename_konfera, verbose_name='materialy'), + ), + migrations.AlterField( + model_name='konfera', + name='prezentace', + field=models.FileField(blank=True, help_text='Prezentace nebo fotka posteru', upload_to=seminar.models.generate_filename_konfera, verbose_name='prezentace'), + ), + migrations.AddField( + model_name='konfera', + name='prispevek', + field=models.ForeignKey(blank=True, help_text='Účastnický přípěvek o konfeře', null=True, on_delete=django.db.models.deletion.SET_NULL, related_name='konfery', to='seminar.Problem', verbose_name='příspěvek do čísla'), + ), + migrations.AddField( + model_name='cislo', + name='faze', + field=models.CharField(choices=[('admin', 'Úpravy na webu'), ('tex', 'Úpravy v TeXu'), ('nahrano', 'Nahráno na web')], default='admin', help_text='Během fáze "Úpravy na webu" se obsah čísla vytváří (a případně komentuje) ve webovém rozhraní. Během fáze "Úpravy v TeXu" už obsah ve webovém rozhraní editovat nelze a návrhy na úpravy se píší do korekturovátka a zanášejí do gitu. Z něj se pak vygeneruje verze pro web a číslo se přepne do fáze "Nahráno na web", což jen znamená, že už nejde automaticky stáhnout obsah pro založení čísla v TeXu.', max_length=32, verbose_name='Fáze vytváření obsahu'), + ), + migrations.AddField( + model_name='cislo', + name='datum_deadline_soustredeni', + field=models.DateField(blank=True, help_text='Datum pro příjem řešení pro účast na soustředění', null=True, verbose_name='datum deadline soustředění'), + ), + migrations.CreateModel( + name='Osoba', + fields=[ + ('id', models.AutoField(primary_key=True, serialize=False)), + ('jmeno', models.CharField(max_length=256, verbose_name='jméno')), + ('prijmeni', models.CharField(max_length=256, verbose_name='příjmení')), + ('prezdivka', models.CharField(max_length=256, verbose_name='přezdívka')), + ('pohlavi_muz', models.BooleanField(default=False, verbose_name='pohlaví (muž)')), + ('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')), + ('datum_narozeni', models.DateField(blank=True, null=True, verbose_name='datum narození')), + ('datum_souhlasu_udaje', models.DateField(blank=True, help_text='Datum souhlasu se zpracováním osobních údajů', null=True, verbose_name='datum souhlasu (údaje)')), + ('datum_souhlasu_zasilani', models.DateField(blank=True, help_text='Datum souhlasu se zasíláním MFF materiálů', null=True, verbose_name='datum souhlasu (spam)')), + ('datum_registrace', models.DateField(default=django.utils.timezone.now, verbose_name='datum registrace do semináře')), + ('ulice', models.CharField(blank=True, default='', max_length=256, verbose_name='ulice')), + ('mesto', models.CharField(blank=True, default='', max_length=256, verbose_name='město')), + ('psc', models.CharField(blank=True, default='', max_length=32, verbose_name='PSČ')), + ('stat', django_countries.fields.CountryField(default='CZ', help_text='ISO 3166-1 kód země velkými písmeny (CZ, SK, ...)', max_length=2, verbose_name='stát')), + ('poznamka', models.TextField(blank=True, help_text='Neveřejná poznámka k osobě (plain text)', verbose_name='neveřejná poznámka')), + ('foto', imagekit.models.fields.ProcessedImageField(blank=True, help_text='Vlož fotografii osoby o libovolné velikosti', null=True, upload_to='image_osoby/velke/%Y/', verbose_name='Fotografie osoby')), + ('user', models.OneToOneField(blank=True, null=True, on_delete=django.db.models.deletion.CASCADE, to=settings.AUTH_USER_MODEL, verbose_name='uživatel')), + ], + options={ + 'verbose_name': 'Osoba', + 'verbose_name_plural': 'Osoby', + 'db_table': 'seminar_osoby', + 'ordering': ['prijmeni', 'jmeno'], + }, + ), + migrations.CreateModel( + name='Prijemce', + fields=[ + ('id', models.AutoField(primary_key=True, serialize=False)), + ('poznamka', models.TextField(blank=True, help_text='Neveřejná poznámka k příemci čísel (plain text)', verbose_name='neveřejná poznámka')), + ('osoba', models.ForeignKey(help_text='Které osobě či na jakou adresu se mají zasílat čísla', on_delete=django.db.models.deletion.CASCADE, to='seminar.Osoba', verbose_name='komu')), + ], + options={ + 'verbose_name': 'příjemce', + 'verbose_name_plural': 'příjemce', + 'db_table': 'seminar_prijemce', + }, + ), + migrations.CreateModel( + name='Text', + fields=[ + ('id', models.AutoField(auto_created=True, primary_key=True, serialize=False, verbose_name='ID')), + ('na_web', models.TextField(blank=True, help_text='Text ke zveřejnění na webu', verbose_name='text na web')), + ('do_cisla', models.TextField(blank=True, help_text='Text ke zveřejnění v čísle', verbose_name='text do čísla')), + ], + options={ + 'verbose_name': 'text', + 'verbose_name_plural': 'texty', + 'db_table': 'seminar_texty', + }, + ), + migrations.CreateModel( + name='Uloha', + fields=[ + ('problem_ptr', models.OneToOneField(auto_created=True, on_delete=django.db.models.deletion.CASCADE, parent_link=True, primary_key=True, serialize=False, to='seminar.Problem')), + ('max_body', models.DecimalField(blank=True, decimal_places=1, max_digits=8, null=True, verbose_name='maximum bodů')), + ], + options={ + 'verbose_name': 'Úloha', + 'verbose_name_plural': 'Úlohy', + 'db_table': 'seminar_ulohy', + }, + bases=('seminar.problem',), + ), + migrations.AlterModelOptions( + name='novinky', + options={'ordering': ['-datum'], 'verbose_name': 'Novinka', 'verbose_name_plural': 'Novinky'}, + ), + migrations.AlterModelOptions( + name='prilohareseni', + options={'ordering': ['reseni', 'vytvoreno'], 'verbose_name': 'Příloha řešení', 'verbose_name_plural': 'Přílohy řešení'}, + ), + migrations.AlterModelOptions( + name='reseni', + options={'ordering': ['-cas_doruceni'], 'verbose_name': 'Řešení', 'verbose_name_plural': 'Řešení'}, + ), + migrations.AlterModelOptions( + name='resitel', + options={'ordering': ['osoba'], 'verbose_name': 'Řešitel', 'verbose_name_plural': 'Řešitelé'}, + ), + migrations.RenameField( + model_name='konfera', + old_name='org_poznamka', + new_name='poznamka', + ), + migrations.RenameField( + model_name='reseni', + old_name='timestamp', + new_name='cas_doruceni', + ), + migrations.RenameField( + model_name='prilohareseni', + old_name='timestamp', + new_name='vytvoreno', + ), + migrations.RenameField( + model_name='problem', + old_name='text_org', + new_name='poznamka', + ), + migrations.RenameField( + model_name='problem', + old_name='timestamp', + new_name='vytvoreno', + ), + migrations.RenameField( + model_name='problem', + old_name='cislo_zadani', + new_name='cislo_zadani_old', + ), + migrations.RenameField( + model_name='problem', + old_name='cislo_reseni', + new_name='cislo_reseni_old', + ), + migrations.AddField( + model_name='konfera', + name='anotace', + field=models.TextField(blank=True, help_text='Popis, o čem bude konfera.', verbose_name='anotace'), + ), + migrations.AddField( + model_name='organizator', + name='organizuje_do', + field=models.DateTimeField(blank=True, null=True, verbose_name='Organizuje do'), + ), + migrations.AddField( + model_name='organizator', + name='organizuje_od', + field=models.DateTimeField(blank=True, null=True, verbose_name='Organizuje od'), + ), + migrations.AddField( + model_name='organizator', + name='skola', + field=models.CharField(blank=True, help_text='Škola, např. MFF, VŠCHT, VUT, ... prostě aby se nemuselo psát do studuješkolu, ale jen obor, možnost zobrazit zvlášť', max_length=256, null=True, verbose_name='Škola, kterou studuje'), + ), + migrations.AddField( + model_name='organizator', + name='vytvoreno', + field=models.DateTimeField(blank=True, default=django.utils.timezone.now, editable=False, verbose_name='Vytvořeno'), + ), + migrations.AddField( + model_name='problem', + name='garant', + field=models.ForeignKey(blank=True, null=True, on_delete=django.db.models.deletion.CASCADE, related_name='garant_problemu_problem', to='seminar.Organizator', verbose_name='garant zadaného problému'), + ), + migrations.AddField( + model_name='problem', + name='nadproblem', + field=models.ForeignKey(blank=True, null=True, on_delete=django.db.models.deletion.CASCADE, related_name='nadproblem_problem', to='seminar.Problem', verbose_name='nadřazený problém'), + ), + migrations.AddField( + model_name='problem', + name='opravovatele', + field=models.ManyToManyField(blank=True, related_name='opravovatele_problem', to='seminar.Organizator', verbose_name='opravovatelé'), + ), + migrations.AddField( + model_name='reseni', + name='zverejneno', + field=models.BooleanField(default=False, help_text='Udává, zda je řešení zveřejněno', verbose_name='řešení zveřejněno'), + ), + migrations.AlterField( + model_name='cislo', + name='verejna_vysledkovka', + field=models.BooleanField(default=False, help_text='Je-li false u veřejného čísla,\t\t\t\t není výsledkovka zatím veřejná.', verbose_name='zveřejněna výsledkovka'), + ), + migrations.AlterField( + model_name='cislo', + name='verejne_db', + field=models.BooleanField(db_column='verejne', default=False, verbose_name='číslo zveřejněno'), + ), + migrations.AlterField( + model_name='konfera', + name='typ_prezentace', + field=models.CharField(choices=[('veletrh', 'Veletrh (postery)'), ('prezentace', 'Prezentace (přednáška)')], default='veletrh', max_length=16, verbose_name='typ prezentace'), + ), + migrations.RenameField( + model_name='novinky', + old_name='autor', + new_name='autor_old', + ), + migrations.AddField( + model_name='novinky', + name='autor', + field=models.ForeignKey(null=True, on_delete=django.db.models.deletion.CASCADE, to='seminar.Organizator', verbose_name='Autor novinky'), + ), + migrations.AlterField( + model_name='novinky', + name='obrazek', + field=models.ImageField(blank=True, null=True, upload_to='image_novinky/%Y/%m/%d/', verbose_name='Obrázek'), + ), + migrations.AlterField( + model_name='novinky', + name='text', + field=models.TextField(blank=True, null=True, verbose_name='Text novinky'), + ), + migrations.AlterField( + model_name='novinky', + name='zverejneno', + field=models.BooleanField(default=False, verbose_name='Zveřejněno'), + ), + migrations.AlterField( + model_name='organizator', + name='strucny_popis_organizatora', + field=models.TextField(blank=True, null=True, verbose_name='Stručný popis organizátora'), + ), + migrations.AlterField( + model_name='organizator', + name='studuje', + field=models.CharField(blank=True, help_text="Např. 'Studuje Obecnou fyziku (Bc.), 3. ročník', 'Vystudovala Diskrétní modely a algoritmy (Mgr.)' nebo 'Přednáší na MFF'", max_length=256, null=True, verbose_name='Studium aj.'), + ), + migrations.CreateModel( + name='Pohadka', + fields=[ + ('id', models.AutoField(primary_key=True, serialize=False)), + ('text', models.TextField(verbose_name='Text pohádky')), + ('pred', models.BooleanField(default=True, verbose_name='Před úlohou')), + ('vytvoreno', models.DateTimeField(blank=True, default=django.utils.timezone.now, editable=False, verbose_name='Vytvořeno')), + ('autor_old', models.ForeignKey(null=True, on_delete=django.db.models.deletion.CASCADE, to=settings.AUTH_USER_MODEL, verbose_name=b'Autor poh\xc3\xa1dky')), + ('uloha_old', models.ForeignKey(on_delete=django.db.models.deletion.CASCADE, related_name='pohadky', to='seminar.Problem', verbose_name='Úloha')), + ('autor', models.ForeignKey(null=True, on_delete=django.db.models.deletion.CASCADE, to='seminar.Organizator', verbose_name='Autor pohádky')), + ('uloha', models.ForeignKey(null=True, on_delete=django.db.models.deletion.CASCADE, related_name='pohadky', to='seminar.Uloha', verbose_name='Úloha')), + ], + options={ + 'ordering': ['uloha__cislo_zadani', 'uloha__kod', '-pred'], + 'db_table': 'seminar_pohadky', + 'verbose_name': 'Pohádka', + 'verbose_name_plural': 'Pohádky', + }, + ), + migrations.RenameField( + model_name='problem', + old_name='autor', + new_name='autor_old', + ), + migrations.AddField( + model_name='problem', + name='autor', + field=models.ForeignKey(blank=True, null=True, on_delete=django.db.models.deletion.CASCADE, related_name='autor_problemu_problem', to='seminar.Organizator', verbose_name='autor problému'), + ), + migrations.AlterField( + model_name='problem', + name='kod', + field=models.CharField(blank=True, default='', help_text='Číslo/kód úlohy v čísle nebo kód tématu/článku/seriálu v ročníku', max_length=32, verbose_name='lokální kód'), + ), + migrations.AlterField( + model_name='problem', + name='stav', + field=models.CharField(choices=[('navrh', 'Návrh'), ('zadany', 'Zadaný'), ('vyreseny', 'Vyřešený'), ('smazany', 'Smazaný')], default='navrh', max_length=32, verbose_name='stav problému'), + ), + migrations.AlterField( + model_name='problem', + name='zamereni', + field=taggit.managers.TaggableManager(blank=True, help_text='Zaměření M/F/I/O problému, příp. další tagy', through='taggit.TaggedItem', to='taggit.Tag', verbose_name='zaměření'), + ), + migrations.AlterField( + model_name='reseni', + name='forma', + field=models.CharField(choices=[('papir', 'Papírové řešení'), ('email', 'Emailem'), ('upload', 'Upload přes web')], default='email', max_length=16, verbose_name='forma řešení'), + ), + migrations.RenameField( + model_name='reseni', + old_name='problem', + new_name='problem_old', + ), + migrations.AlterField( + model_name='resitel', + name='zasilat', + field=models.CharField(choices=[('domu', 'Domů'), ('do_skoly', 'Do školy'), ('nikam', 'Nikam')], default='domu', max_length=32, verbose_name='kam zasílat'), + ), + migrations.AlterField( + model_name='rocnik', + name='exportovat', + field=models.BooleanField(db_column='exportovat', default=False, help_text='Exportuje se jen podle tohoto flagu (ne veřejnosti), a to jen čísla s veřejnou výsledkovkou', verbose_name='export do AESOPa'), + ), + migrations.AlterField( + model_name='skola', + name='aesop_id', + field=models.CharField(blank=True, default='', help_text='Aesopi ID typu "izo:..." nebo "aesop:..."', max_length=32, verbose_name='Aesop ID'), + ), + migrations.AlterField( + model_name='skola', + name='kratky_nazev', + field=models.CharField(blank=True, help_text='Zkrácený název pro zobrazení ve výsledkovce', max_length=256, verbose_name='zkrácený název'), + ), + migrations.AlterField( + model_name='skola', + name='stat', + field=django_countries.fields.CountryField(default='CZ', help_text='ISO 3166-1 kód země velkými písmeny (CZ, SK, ...)', max_length=2, verbose_name='stát'), + ), + migrations.AlterField( + model_name='soustredeni', + name='exportovat', + field=models.BooleanField(db_column='exportovat', default=False, help_text='Exportuje se jen podle tohoto flagu (ne veřejnosti)', verbose_name='export do AESOPa'), + ), + migrations.AlterField( + model_name='soustredeni', + name='misto', + field=models.CharField(blank=True, default='', help_text='Místo (název obce, volitelně též objektu', max_length=256, verbose_name='místo soustředění'), + ), + migrations.AlterField( + model_name='soustredeni', + name='text', + field=models.TextField(blank=True, default='', verbose_name='text k soustředění (HTML)'), + ), + migrations.AlterField( + model_name='soustredeni', + name='typ', + field=models.CharField(choices=[('jarni', 'Jarní soustředění'), ('podzimni', 'Podzimní soustředění'), ('vikend', 'Víkendový sraz')], default='podzimni', max_length=16, verbose_name='typ akce'), + ), + migrations.AlterField( + model_name='soustredeni', + name='verejne_db', + field=models.BooleanField(db_column='verejne', default=False, verbose_name='soustředění zveřejněno'), + ), + migrations.AlterModelTable( + name='problem', + table='seminar_problemy', + ), + migrations.AddField( + model_name='uloha', + name='cislo_deadline', + field=models.ForeignKey(blank=True, null=True, on_delete=django.db.models.deletion.CASCADE, related_name='deadlinove_ulohy', to='seminar.Cislo', verbose_name='číslo deadlinu'), + ), + migrations.AddField( + model_name='uloha', + name='cislo_reseni', + field=models.ForeignKey(blank=True, help_text='Číslo s řešením úlohy, jen pro úlohy', null=True, on_delete=django.db.models.deletion.CASCADE, related_name='resene_ulohy', to='seminar.Cislo', verbose_name='číslo řešení'), + ), + migrations.AddField( + model_name='uloha', + name='cislo_zadani', + field=models.ForeignKey(blank=True, null=True, on_delete=django.db.models.deletion.CASCADE, related_name='zadane_ulohy', to='seminar.Cislo', verbose_name='číslo zadání'), + ), + migrations.CreateModel( + name='Tema', + fields=[ + ('problem_ptr', models.OneToOneField(auto_created=True, on_delete=django.db.models.deletion.CASCADE, parent_link=True, primary_key=True, serialize=False, to='seminar.Problem')), + ('tema_typ', models.CharField(choices=[('tema', 'Téma'), ('serial', 'Seriál')], default='tema', max_length=16, verbose_name='Typ tématu')), + ('rocnik', models.ForeignKey(blank=True, null=True, on_delete=django.db.models.deletion.CASCADE, to='seminar.Rocnik', verbose_name='ročník')), + ], + options={ + 'verbose_name': 'Téma', + 'verbose_name_plural': 'Témata', + 'db_table': 'seminar_temata', + }, + bases=('seminar.problem',), + ), + migrations.CreateModel( + name='Reseni_Resitele', + fields=[ + ('id', models.AutoField(primary_key=True, serialize=False)), + ('reseni', models.ForeignKey(on_delete=django.db.models.deletion.CASCADE, to='seminar.Reseni', verbose_name='řešení')), + ('resitele', models.ForeignKey(on_delete=django.db.models.deletion.CASCADE, to='seminar.Resitel', verbose_name='řešitel')), + ], + options={ + 'verbose_name': 'Řešení řešitelů', + 'verbose_name_plural': 'Řešení řešitelů', + 'db_table': 'seminar_reseni_resitele', + 'ordering': ['reseni', 'resitele'], + }, + ), + migrations.CreateModel( + name='Obrazek', + fields=[ + ('id', models.AutoField(primary_key=True, serialize=False)), + ('na_web', models.ImageField(blank=True, null=True, upload_to='obrazky/%Y/%m/%d/', verbose_name='obrázek na web')), + ('do_cisla_barevny', models.FileField(blank=True, help_text='Barevná verze obrázku do čísla', null=True, upload_to='obrazky/%Y/%m/%d/', verbose_name='barevný obrázek do čísla')), + ('do_cisla_cernobily', models.FileField(blank=True, help_text='Černobílá verze obrázku do čísla', null=True, upload_to='obrazky/%Y/%m/%d/', verbose_name='černobílý obrázek do čísla')), + ('text', models.ForeignKey(help_text='text, ve kterém se obrázek vyskytuje', on_delete=django.db.models.deletion.CASCADE, to='seminar.Text', verbose_name='text')), + ], + options={ + 'verbose_name': 'obrázek', + 'verbose_name_plural': 'obrázky', + 'db_table': 'seminar_obrazky', + }, + ), + migrations.CreateModel( + name='Hodnoceni', + fields=[ + ('id', models.AutoField(primary_key=True, serialize=False)), + ('body', models.DecimalField(decimal_places=1, max_digits=8, verbose_name='body')), + ('cislo_body', models.ForeignKey(on_delete=django.db.models.deletion.CASCADE, related_name='hodnoceni', to='seminar.Cislo', verbose_name='číslo pro body')), + ('problem', models.ForeignKey(on_delete=django.db.models.deletion.CASCADE, to='seminar.Problem', verbose_name='problém')), + ('reseni', models.ForeignKey(on_delete=django.db.models.deletion.CASCADE, to='seminar.Reseni', verbose_name='řešení')), + ], + options={ + 'verbose_name': 'Hodnocení', + 'verbose_name_plural': 'Hodnocení', + 'db_table': 'seminar_hodnoceni', + }, + ), + migrations.CreateModel( + name='Clanek', + fields=[ + ('problem_ptr', models.OneToOneField(auto_created=True, on_delete=django.db.models.deletion.CASCADE, parent_link=True, primary_key=True, serialize=False, to='seminar.Problem')), + ('cislo', models.ForeignKey(blank=True, null=True, on_delete=django.db.models.deletion.CASCADE, to='seminar.Cislo', verbose_name='číslo')), + ], + options={ + 'verbose_name': 'Článek', + 'verbose_name_plural': 'Články', + 'db_table': 'seminar_clanky', + }, + bases=('seminar.problem',), + ), + migrations.AddField( + model_name='reseni', + name='resitele', + field=models.ManyToManyField(help_text='Seznam autorů řešení', through='seminar.Reseni_Resitele', to='seminar.Resitel', verbose_name='autoři řešení'), + ), + migrations.AddField( + model_name='reseni', + name='text_cely', + field=models.OneToOneField(blank=True, null=True, on_delete=django.db.models.deletion.CASCADE, related_name='reseni_cely_set', to='seminar.Text', verbose_name='Plná verze textu řešení'), + ), + migrations.AddField( + model_name='reseni', + name='text_zkraceny', + field=models.ManyToManyField(help_text='Seznam úryvků z řešení', related_name='reseni_zkraceny_set', to='seminar.Text', verbose_name='zkrácené verze řešení'), + ), + migrations.AddField( + model_name='skola', + name='kontaktni_osoba', + field=models.ForeignKey(blank=True, null=True, on_delete=django.db.models.deletion.CASCADE, to='seminar.Osoba', verbose_name='Kontaktní osoba'), + ), + migrations.AddField( + model_name='reseni', + name='problem', + field=models.ManyToManyField(help_text='Problém', through='seminar.Hodnoceni', to='seminar.Problem', verbose_name='problém'), + ), + migrations.AddField( + model_name='konfera', + name='reseni', + field=models.OneToOneField(blank=True, help_text='Účastnický přípěvek o konfeře', null=True, on_delete=django.db.models.deletion.SET_NULL, related_name='konfery', to='seminar.Reseni', verbose_name='článek ke konfeře'), + ), + migrations.AddField( + model_name='organizator', + name='osoba', + field=models.OneToOneField(help_text='osobní údaje organizátora', null=True, on_delete=django.db.models.deletion.CASCADE, related_name='org', to='seminar.Osoba', verbose_name='osoba'), + ), + migrations.AddField( + model_name='resitel', + name='osoba', + field=models.OneToOneField(null=True, on_delete=django.db.models.deletion.CASCADE, to='seminar.Osoba', verbose_name='osoba'), + ), + migrations.CreateModel( + name='TreeNode', + fields=[ + ('id', models.AutoField(auto_created=True, primary_key=True, serialize=False, verbose_name='ID')), + ('first_child', models.ForeignKey(blank=True, null=True, on_delete=django.db.models.deletion.SET_NULL, to='seminar.TreeNode', verbose_name='první potomek')), + ('root', models.ForeignKey(null=True, on_delete=django.db.models.deletion.SET_NULL, related_name='potomci_set', to='seminar.TreeNode', verbose_name='kořen stromu')), + ('succ', models.OneToOneField(blank=True, null=True, on_delete=django.db.models.deletion.SET_NULL, related_name='prev', to='seminar.TreeNode', verbose_name='další element na stejné úrovni')), + ], + options={ + 'verbose_name': 'TreeNode', + 'verbose_name_plural': 'TreeNody', + 'db_table': 'seminar_nodes_treenode', + }, + ), + migrations.CreateModel( + name='CisloNode', + fields=[ + ('treenode_ptr', models.OneToOneField(auto_created=True, on_delete=django.db.models.deletion.CASCADE, parent_link=True, primary_key=True, serialize=False, to='seminar.TreeNode')), + ('cislo', models.OneToOneField(on_delete=django.db.models.deletion.PROTECT, to='seminar.Cislo', verbose_name='číslo')), + ], + options={ + 'verbose_name': 'Číslo (Node)', + 'verbose_name_plural': 'Čísla (Node)', + 'db_table': 'seminar_nodes_cislo', + }, + bases=('seminar.treenode',), + ), + migrations.CreateModel( + name='ClanekNode', + fields=[ + ('treenode_ptr', models.OneToOneField(auto_created=True, on_delete=django.db.models.deletion.CASCADE, parent_link=True, primary_key=True, serialize=False, to='seminar.TreeNode')), + ('clanek', models.OneToOneField(null=True, on_delete=django.db.models.deletion.PROTECT, to='seminar.Clanek', verbose_name='článek')), + ], + options={ + 'verbose_name': 'Článek (Node)', + 'verbose_name_plural': 'Články (Node)', + 'db_table': 'seminar_nodes_clanek', + }, + bases=('seminar.treenode',), + ), + migrations.CreateModel( + name='KonferaNode', + fields=[ + ('treenode_ptr', models.OneToOneField(auto_created=True, on_delete=django.db.models.deletion.CASCADE, parent_link=True, primary_key=True, serialize=False, to='seminar.TreeNode')), + ('konfera', models.OneToOneField(null=True, on_delete=django.db.models.deletion.PROTECT, to='seminar.Konfera', verbose_name='konfera')), + ], + options={ + 'verbose_name': 'Konfera (Node)', + 'verbose_name_plural': 'Konfery (Node)', + 'db_table': 'seminar_nodes_konfera', + }, + bases=('seminar.treenode',), + ), + migrations.CreateModel( + name='MezicisloNode', + fields=[ + ('treenode_ptr', models.OneToOneField(auto_created=True, on_delete=django.db.models.deletion.CASCADE, parent_link=True, primary_key=True, serialize=False, to='seminar.TreeNode')), + ], + options={ + 'verbose_name': 'Mezičíslo (Node)', + 'verbose_name_plural': 'Mezičísla (Node)', + 'db_table': 'seminar_nodes_mezicislo', + }, + bases=('seminar.treenode',), + ), + migrations.CreateModel( + name='RocnikNode', + fields=[ + ('treenode_ptr', models.OneToOneField(auto_created=True, on_delete=django.db.models.deletion.CASCADE, parent_link=True, primary_key=True, serialize=False, to='seminar.TreeNode')), + ('rocnik', models.OneToOneField(on_delete=django.db.models.deletion.PROTECT, to='seminar.Rocnik', verbose_name='ročník')), + ], + options={ + 'verbose_name': 'Ročník (Node)', + 'verbose_name_plural': 'Ročníky (Node)', + 'db_table': 'seminar_nodes_rocnik', + }, + bases=('seminar.treenode',), + ), + migrations.CreateModel( + name='TemaVCisleNode', + fields=[ + ('treenode_ptr', models.OneToOneField(auto_created=True, on_delete=django.db.models.deletion.CASCADE, parent_link=True, primary_key=True, serialize=False, to='seminar.TreeNode')), + ('tema', models.ForeignKey(on_delete=django.db.models.deletion.PROTECT, to='seminar.Tema', verbose_name='téma v čísle')), + ], + options={ + 'verbose_name': 'Téma v čísle (Node)', + 'verbose_name_plural': 'Témata v čísle (Node)', + 'db_table': 'seminar_nodes_temavcisle', + }, + bases=('seminar.treenode',), + ), + migrations.CreateModel( + name='TextNode', + fields=[ + ('treenode_ptr', models.OneToOneField(auto_created=True, on_delete=django.db.models.deletion.CASCADE, parent_link=True, primary_key=True, serialize=False, to='seminar.TreeNode')), + ('text', models.ForeignKey(on_delete=django.db.models.deletion.PROTECT, to='seminar.Text', verbose_name='text')), + ], + options={ + 'verbose_name': 'Text (Node)', + 'verbose_name_plural': 'Text (Node)', + 'db_table': 'seminar_nodes_obsah', + }, + bases=('seminar.treenode',), + ), + migrations.CreateModel( + name='UlohaVzorakNode', + fields=[ + ('treenode_ptr', models.OneToOneField(auto_created=True, on_delete=django.db.models.deletion.CASCADE, parent_link=True, primary_key=True, serialize=False, to='seminar.TreeNode')), + ('uloha', models.OneToOneField(null=True, on_delete=django.db.models.deletion.PROTECT, to='seminar.Uloha', verbose_name='úloha')), + ], + options={ + 'verbose_name': 'Vzorák úlohy (Node)', + 'verbose_name_plural': 'Vzoráky úloh (Node)', + 'db_table': 'seminar_nodes_uloha_vzorak', + }, + bases=('seminar.treenode',), + ), + migrations.CreateModel( + name='UlohaZadaniNode', + fields=[ + ('treenode_ptr', models.OneToOneField(auto_created=True, on_delete=django.db.models.deletion.CASCADE, parent_link=True, primary_key=True, serialize=False, to='seminar.TreeNode')), + ('uloha', models.OneToOneField(null=True, on_delete=django.db.models.deletion.PROTECT, to='seminar.Uloha', verbose_name='úloha')), + ], + options={ + 'verbose_name': 'Zadání úlohy (Node)', + 'verbose_name_plural': 'Zadání úloh (Node)', + 'db_table': 'seminar_nodes_uloha_zadani', + }, + bases=('seminar.treenode',), + ), + migrations.CreateModel( + name='PohadkaNode', + fields=[ + ('treenode_ptr', models.OneToOneField(auto_created=True, on_delete=django.db.models.deletion.CASCADE, parent_link=True, primary_key=True, serialize=False, to='seminar.TreeNode')), + ('pohadka', models.OneToOneField(on_delete=django.db.models.deletion.PROTECT, to='seminar.Pohadka', verbose_name='pohádka')), + ], + options={ + 'verbose_name': 'Pohádka (Node)', + 'verbose_name_plural': 'Pohádky (Node)', + 'db_table': 'seminar_nodes_pohadka', + }, + bases=('seminar.treenode',), + ), + + # migr 0051 + migrations.RunPython( + resitel_to_osoba, + reverse_code=osoba_to_resitel, + ), + + # migr 0052 + migrations.RunPython( + spoj_k_organizatorum_osoby, + ), + migrations.RunPython( + fix_problem, + ), + migrations.RunPython( + fix_pohadka, + ), + migrations.RunPython( + fix_novinka, + ), + + # migr 0053 + migrations.RunPython( + rok_to_datetime, + reverse_code=datetime_to_rok, + ), + + 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', + ), + + # migr 0056 + migrations.RunPython( + generuj_RocnikNody_a_CisloNody, + ), + + # migr 0057 + migrations.RunPython( + reseni_to_Reseni, + ), + + # migr 0058 + migrations.RunPython( + uloha_to_Uloha, + ), + migrations.RunPython( + tema_to_Tema, + ), + migrations.RunPython( + clanek_to_Clanek, + ), + migrations.RunPython( + konfery_rucne, + ), + + # migr 0059 + migrations.RunPython( + vytvor_pohadkanode, + ), + + # migr 0060 + migrations.RunPython( + pokacej_les, + ), + + migrations.RemoveField( + model_name='novinky', + name='autor_old', + ), + migrations.RemoveField( + model_name='organizator', + name='foto', + ), + migrations.RemoveField( + model_name='organizator', + name='organizuje_do_roku', + ), + migrations.RemoveField( + model_name='organizator', + name='organizuje_od_roku', + ), + migrations.RemoveField( + model_name='organizator', + name='prezdivka', + ), + migrations.RemoveField( + model_name='organizator', + name='user', + ), + migrations.RemoveField( + model_name='pohadka', + name='autor_old', + ), + migrations.RemoveField( + model_name='pohadka', + name='uloha_old', + ), + migrations.RemoveField( + model_name='problem', + name='autor_old', + ), + migrations.RemoveField( + model_name='problem', + name='body', + ), + migrations.RemoveField( + model_name='problem', + name='cislo_reseni_old', + ), + migrations.RemoveField( + model_name='problem', + name='cislo_zadani_old', + ), + migrations.RemoveField( + model_name='problem', + name='opravovatel', + ), + migrations.RemoveField( + model_name='problem', + name='text_reseni', + ), + migrations.RemoveField( + model_name='problem', + name='text_zadani', + ), + migrations.RemoveField( + model_name='problem', + name='typ', + ), + migrations.RemoveField( + model_name='reseni', + name='body', + ), + migrations.RemoveField( + model_name='reseni', + name='cislo_body', + ), + migrations.RemoveField( + model_name='reseni', + name='problem_old', + ), + migrations.RemoveField( + model_name='reseni', + name='resitel', + ), + migrations.RemoveField( + model_name='resitel', + name='datum_narozeni', + ), + migrations.RemoveField( + model_name='resitel', + name='datum_prihlaseni', + ), + migrations.RemoveField( + model_name='resitel', + name='datum_souhlasu_udaje', + ), + migrations.RemoveField( + model_name='resitel', + name='datum_souhlasu_zasilani', + ), + migrations.RemoveField( + model_name='resitel', + name='email', + ), + migrations.RemoveField( + model_name='resitel', + name='jmeno', + ), + migrations.RemoveField( + model_name='resitel', + name='mesto', + ), + migrations.RemoveField( + model_name='resitel', + name='pohlavi_muz', + ), + migrations.RemoveField( + model_name='resitel', + name='prijmeni', + ), + migrations.RemoveField( + model_name='resitel', + name='psc', + ), + migrations.RemoveField( + model_name='resitel', + name='stat', + ), + migrations.RemoveField( + model_name='resitel', + name='telefon', + ), + migrations.RemoveField( + model_name='resitel', + name='ulice', + ), + migrations.RemoveField( + model_name='resitel', + name='user', + ), + migrations.AlterModelOptions( + name='pohadka', + options={'ordering': ['vytvoreno'], 'verbose_name': 'Pohádka', 'verbose_name_plural': 'Pohádky'}, + ), + migrations.RemoveField( + model_name='pohadka', + name='pred', + ), + migrations.RemoveField( + model_name='pohadka', + name='text', + ), + migrations.RemoveField( + model_name='pohadka', + name='uloha', + ), + migrations.AlterField( + model_name='cislo', + name='verejna_vysledkovka', + field=models.BooleanField(default=False, help_text='Je-li false u veřejného čísla, není výsledkovka zatím veřejná.', verbose_name='zveřejněna výsledkovka'), + ), + migrations.AlterField( + model_name='prijemce', + name='osoba', + field=models.OneToOneField(help_text='Které osobě či na jakou adresu se mají zasílat čísla', on_delete=django.db.models.deletion.CASCADE, to='seminar.Osoba', verbose_name='komu'), + ), + migrations.AlterField( + model_name='reseni', + name='cas_doruceni', + field=models.DateTimeField(blank=True, default=django.utils.timezone.now, verbose_name='čas_doručení'), + ), + migrations.AlterField( + model_name='cislo', + name='rocnik', + field=models.ForeignKey(on_delete=django.db.models.deletion.PROTECT, related_name='cisla', to='seminar.Rocnik', verbose_name='ročník'), + ), + migrations.AlterField( + model_name='clanek', + name='cislo', + field=models.ForeignKey(blank=True, null=True, on_delete=django.db.models.deletion.PROTECT, to='seminar.Cislo', verbose_name='číslo'), + ), + migrations.AlterField( + model_name='hodnoceni', + name='cislo_body', + field=models.ForeignKey(on_delete=django.db.models.deletion.PROTECT, related_name='hodnoceni', to='seminar.Cislo', verbose_name='číslo pro body'), + ), + migrations.AlterField( + model_name='hodnoceni', + name='problem', + field=models.ForeignKey(on_delete=django.db.models.deletion.PROTECT, to='seminar.Problem', verbose_name='problém'), + ), + migrations.AlterField( + model_name='konfery_ucastnici', + name='konfera', + field=models.ForeignKey(on_delete=django.db.models.deletion.CASCADE, to='seminar.Konfera', verbose_name='konfera'), + ), + migrations.AlterField( + model_name='konfery_ucastnici', + name='resitel', + field=models.ForeignKey(on_delete=django.db.models.deletion.PROTECT, to='seminar.Resitel', verbose_name='řešitel'), + ), + migrations.AlterField( + model_name='nastaveni', + name='aktualni_cislo', + field=models.ForeignKey(on_delete=django.db.models.deletion.PROTECT, to='seminar.Cislo', verbose_name='poslední vydané číslo'), + ), + migrations.AlterField( + model_name='nastaveni', + name='aktualni_rocnik', + field=models.ForeignKey(on_delete=django.db.models.deletion.PROTECT, to='seminar.Rocnik', verbose_name='aktuální ročník'), + ), + migrations.AlterField( + model_name='novinky', + name='autor', + field=models.ForeignKey(null=True, on_delete=django.db.models.deletion.SET_NULL, to='seminar.Organizator', verbose_name='Autor novinky'), + ), + migrations.AlterField( + model_name='organizator', + name='osoba', + field=models.OneToOneField(help_text='osobní údaje organizátora', null=True, on_delete=django.db.models.deletion.SET_NULL, related_name='org', to='seminar.Osoba', verbose_name='osoba'), + ), + migrations.AlterField( + model_name='osoba', + name='user', + field=models.OneToOneField(blank=True, null=True, on_delete=django.db.models.deletion.DO_NOTHING, to=settings.AUTH_USER_MODEL, verbose_name='uživatel'), + ), + migrations.AlterField( + model_name='pohadka', + name='autor', + field=models.ForeignKey(null=True, on_delete=django.db.models.deletion.SET_NULL, to='seminar.Organizator', verbose_name='Autor pohádky'), + ), + migrations.AlterField( + model_name='problem', + name='autor', + field=models.ForeignKey(blank=True, null=True, on_delete=django.db.models.deletion.SET_NULL, related_name='autor_problemu_problem', to='seminar.Organizator', verbose_name='autor problému'), + ), + migrations.AlterField( + model_name='problem', + name='garant', + field=models.ForeignKey(blank=True, null=True, on_delete=django.db.models.deletion.SET_NULL, related_name='garant_problemu_problem', to='seminar.Organizator', verbose_name='garant zadaného problému'), + ), + migrations.AlterField( + model_name='problem', + name='nadproblem', + field=models.ForeignKey(blank=True, null=True, on_delete=django.db.models.deletion.SET_NULL, related_name='nadproblem_problem', to='seminar.Problem', verbose_name='nadřazený problém'), + ), + migrations.AlterField( + model_name='reseni', + name='text_cely', + field=models.OneToOneField(blank=True, null=True, on_delete=django.db.models.deletion.SET_NULL, related_name='reseni_cely_set', to='seminar.Text', verbose_name='Plná verze textu řešení'), + ), + migrations.AlterField( + model_name='reseni_resitele', + name='resitele', + field=models.ForeignKey(on_delete=django.db.models.deletion.PROTECT, to='seminar.Resitel', verbose_name='řešitel'), + ), + migrations.AlterField( + model_name='resitel', + name='osoba', + field=models.OneToOneField(null=True, on_delete=django.db.models.deletion.SET_NULL, to='seminar.Osoba', verbose_name='osoba'), + ), + migrations.AlterField( + model_name='resitel', + name='skola', + field=models.ForeignKey(blank=True, null=True, on_delete=django.db.models.deletion.SET_NULL, to='seminar.Skola', verbose_name='škola'), + ), + migrations.AlterField( + model_name='skola', + name='kontaktni_osoba', + field=models.ForeignKey(blank=True, null=True, on_delete=django.db.models.deletion.SET_NULL, to='seminar.Osoba', verbose_name='Kontaktní osoba'), + ), + migrations.AlterField( + model_name='soustredeni', + name='rocnik', + field=models.ForeignKey(on_delete=django.db.models.deletion.PROTECT, related_name='soustredeni', to='seminar.Rocnik', verbose_name='ročník'), + ), + migrations.AlterField( + model_name='soustredeni_organizatori', + name='organizator', + field=models.ForeignKey(on_delete=django.db.models.deletion.PROTECT, to='seminar.Organizator', verbose_name='organizátor'), + ), + migrations.AlterField( + model_name='soustredeni_organizatori', + name='soustredeni', + field=models.ForeignKey(on_delete=django.db.models.deletion.PROTECT, to='seminar.Soustredeni', verbose_name='soustředění'), + ), + migrations.AlterField( + model_name='soustredeni_ucastnici', + name='resitel', + field=models.ForeignKey(on_delete=django.db.models.deletion.PROTECT, to='seminar.Resitel', verbose_name='řešitel'), + ), + migrations.AlterField( + model_name='soustredeni_ucastnici', + name='soustredeni', + field=models.ForeignKey(on_delete=django.db.models.deletion.PROTECT, to='seminar.Soustredeni', verbose_name='soustředění'), + ), + migrations.AlterField( + model_name='tema', + name='rocnik', + field=models.ForeignKey(blank=True, null=True, on_delete=django.db.models.deletion.PROTECT, to='seminar.Rocnik', verbose_name='ročník'), + ), + migrations.AlterField( + model_name='uloha', + name='cislo_deadline', + field=models.ForeignKey(blank=True, null=True, on_delete=django.db.models.deletion.PROTECT, related_name='deadlinove_ulohy', to='seminar.Cislo', verbose_name='číslo deadlinu'), + ), + migrations.AlterField( + model_name='uloha', + name='cislo_reseni', + field=models.ForeignKey(blank=True, help_text='Číslo s řešením úlohy, jen pro úlohy', null=True, on_delete=django.db.models.deletion.PROTECT, related_name='resene_ulohy', to='seminar.Cislo', verbose_name='číslo řešení'), + ), + migrations.AlterField( + model_name='uloha', + name='cislo_zadani', + field=models.ForeignKey(blank=True, null=True, on_delete=django.db.models.deletion.PROTECT, related_name='zadane_ulohy', to='seminar.Cislo', verbose_name='číslo zadání'), + ), + migrations.AddField( + model_name='treenode', + name='polymorphic_ctype', + field=models.ForeignKey(editable=False, null=True, on_delete=django.db.models.deletion.CASCADE, related_name='polymorphic_seminar.treenode_set+', to='contenttypes.ContentType'), + ), + migrations.RunPython( + vyrob_treenodum_ctypes, + reverse_code=migrations.RunPython.noop, + ), + migrations.AddField( + model_name='problem', + name='polymorphic_ctype', + field=models.ForeignKey(editable=False, null=True, on_delete=django.db.models.deletion.CASCADE, related_name='polymorphic_seminar.problem_set+', to='contenttypes.ContentType'), + ), + migrations.RunPython( + vyrob_problemum_ctypes, + reverse_code=migrations.RunPython.noop, + ), + migrations.AlterField( + model_name='konfera', + name='nazev', + field=models.CharField(help_text='Název konfery', max_length=100, verbose_name='název konfery'), + ), + ] From 3815b5a8a879b7725f418ccde35ad2ec8fcac37a Mon Sep 17 00:00:00 2001 From: Pavel 'LEdoian' Turinsky Date: Thu, 7 Nov 2019 21:04:27 +0100 Subject: [PATCH 2/4] =?UTF-8?q?Zal=C3=A1man=C3=A9=20SQL,=20aby=20se=20dalo?= =?UTF-8?q?=20=C4=8D=C3=ADst?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../0001_squashed_0067_auto_20190814_0805.py | 148 +++++++++++++++++- 1 file changed, 143 insertions(+), 5 deletions(-) diff --git a/seminar/migrations/0001_squashed_0067_auto_20190814_0805.py b/seminar/migrations/0001_squashed_0067_auto_20190814_0805.py index f1f046af..3cc3be08 100644 --- a/seminar/migrations/0001_squashed_0067_auto_20190814_0805.py +++ b/seminar/migrations/0001_squashed_0067_auto_20190814_0805.py @@ -721,8 +721,35 @@ class Migration(migrations.Migration): field=models.ForeignKey(on_delete=django.db.models.deletion.CASCADE, related_name='cisla', to='seminar.Rocnik', verbose_name='ročník'), ), migrations.RunSQL( - sql="\ncreate view seminar_body_za_cislo as\n select\n sr.cislo_body_id || '-' || sr.resitel_id as id,\n sr.cislo_body_id as cislo_id,\n sr.resitel_id as resitel_id,\n sum(sr.body) as body\n from seminar_reseni as sr\n group by sr.cislo_body_id, sr.resitel_id\n order by body desc;\n\ncreate view seminar_body_k_cislu as\n select\n akt_c.id || '-' || min_bzc.resitel_id as id,\n akt_c.id as cislo_id,\n min_bzc.resitel_id as resitel_id,\n max(akt_bzc.body) as body,\n sum(min_bzc.body) as body_celkem\n from ((seminar_cisla as akt_c\n inner join seminar_cisla as min_c on min_c.rocnik_id = akt_c.rocnik_id and akt_c.cislo >= min_c.cislo)\n inner join seminar_body_za_cislo as min_bzc on min_c.id = min_bzc.cislo_id)\n left outer join seminar_body_za_cislo as akt_bzc on akt_bzc.cislo_id = akt_c.id and akt_bzc.resitel_id = min_bzc.resitel_id \n group by akt_c.id, min_bzc.resitel_id, akt_bzc.resitel_id\n order by body_celkem desc;\n", - reverse_sql='\ndrop view seminar_body_k_cislu;\ndrop view seminar_body_za_cislo;\n', + sql=" + create view seminar_body_za_cislo as + select + sr.cislo_body_id || '-' || sr.resitel_id as id, + sr.cislo_body_id as cislo_id, + sr.resitel_id as resitel_id, + sum(sr.body) as body + from seminar_reseni as sr + group by sr.cislo_body_id, sr.resitel_id + order by body desc; + + create view seminar_body_k_cislu as + select + akt_c.id || '-' || min_bzc.resitel_id as id, + akt_c.id as cislo_id, + min_bzc.resitel_id as resitel_id, + max(akt_bzc.body) as body, + sum(min_bzc.body) as body_celkem + from ((seminar_cisla as akt_c + inner join seminar_cisla as min_c on min_c.rocnik_id = akt_c.rocnik_id and akt_c.cislo >= min_c.cislo) + inner join seminar_body_za_cislo as min_bzc on min_c.id = min_bzc.cislo_id) + left outer join seminar_body_za_cislo as akt_bzc on akt_bzc.cislo_id = akt_c.id and akt_bzc.resitel_id = min_bzc.resitel_id + group by akt_c.id, min_bzc.resitel_id, akt_bzc.resitel_id + order by body_celkem desc; + ", + reverse_sql=' + drop view seminar_body_k_cislu; + drop view seminar_body_za_cislo; + ', ), migrations.AlterField( model_name='reseni', @@ -956,7 +983,31 @@ class Migration(migrations.Migration): field=models.DecimalField(blank=True, decimal_places=1, max_digits=8, null=True, verbose_name='body'), ), migrations.RunSQL( - sql="\ncreate view seminar_body_za_cislo as\n select\n sr.cislo_body_id || '-' || sr.resitel_id as id,\n sr.cislo_body_id as cislo_id,\n sr.resitel_id as resitel_id,\n sum(sr.body) as body\n from seminar_reseni as sr\n group by sr.cislo_body_id, sr.resitel_id\n order by body desc;\n\ncreate view seminar_body_k_cislu as\n select\n akt_c.id || '-' || min_bzc.resitel_id as id,\n akt_c.id as cislo_id,\n min_bzc.resitel_id as resitel_id,\n max(akt_bzc.body) as body,\n sum(min_bzc.body) as body_celkem\n from ((seminar_cisla as akt_c\n inner join seminar_cisla as min_c on min_c.rocnik_id = akt_c.rocnik_id and akt_c.cislo >= min_c.cislo)\n inner join seminar_body_za_cislo as min_bzc on min_c.id = min_bzc.cislo_id)\n left outer join seminar_body_za_cislo as akt_bzc on akt_bzc.cislo_id = akt_c.id and akt_bzc.resitel_id = min_bzc.resitel_id \n group by akt_c.id, min_bzc.resitel_id, akt_bzc.resitel_id\n order by body_celkem desc;\n", + sql=" + create view seminar_body_za_cislo as + select + sr.cislo_body_id || '-' || sr.resitel_id as id, + sr.cislo_body_id as cislo_id, + sr.resitel_id as resitel_id, + sum(sr.body) as body + from seminar_reseni as sr + group by sr.cislo_body_id, sr.resitel_id + order by body desc; + + create view seminar_body_k_cislu as + select + akt_c.id || '-' || min_bzc.resitel_id as id, + akt_c.id as cislo_id, + min_bzc.resitel_id as resitel_id, + max(akt_bzc.body) as body, + sum(min_bzc.body) as body_celkem + from ((seminar_cisla as akt_c + inner join seminar_cisla as min_c on min_c.rocnik_id = akt_c.rocnik_id and akt_c.cislo >= min_c.cislo) + inner join seminar_body_za_cislo as min_bzc on min_c.id = min_bzc.cislo_id) + left outer join seminar_body_za_cislo as akt_bzc on akt_bzc.cislo_id = akt_c.id and akt_bzc.resitel_id = min_bzc.resitel_id + group by akt_c.id, min_bzc.resitel_id, akt_bzc.resitel_id + order by body_celkem desc; + ", ), migrations.CreateModel( name='Novinky', @@ -1007,10 +1058,97 @@ class Migration(migrations.Migration): field=models.CharField(choices=[(b'jarni', 'Jarní soustředění'), (b'podzimni', 'Podzimní soustředění'), (b'vikend', 'Víkendový sraz')], default=b'podzimni', max_length=16, verbose_name='typ akce'), ), migrations.RunSQL( - sql="\ndrop view seminar_body_k_cislu;\ndrop view seminar_body_za_cislo;\n\ncreate view seminar_body_za_cislo as\n select\n seminar_reseni.cislo_body_id || '-' || seminar_reseni.resitel_id as id,\n seminar_reseni.cislo_body_id as cislo_id,\n seminar_reseni.resitel_id as resitel_id,\n seminar_cisla.cislo as cislo,\n seminar_cisla.rocnik_id as rocnik_id,\n seminar_rocniky.rocnik as rocnik,\n seminar_cisla.verejna_vysledkovka as verejna_vysledkovka,\n sum(seminar_reseni.body) as body\n from\n seminar_reseni\n inner join seminar_cisla on seminar_reseni.cislo_body_id = seminar_cisla.id\n inner join seminar_rocniky on seminar_cisla.rocnik_id = seminar_rocniky.id\n group by seminar_reseni.cislo_body_id, seminar_reseni.resitel_id, seminar_cisla.cislo,\n seminar_cisla.rocnik_id, seminar_rocniky.rocnik, seminar_cisla.verejna_vysledkovka\n order by body desc;\n\ncreate view seminar_body_k_cislu_rocnik as\n select\n akt_body.id as id,\n akt_body.cislo_id as cislo_id,\n akt_body.resitel_id as resitel_id,\n akt_body.body as body,\n sum(min_body.body) as body_celkem\n from\n seminar_body_za_cislo as akt_body\n inner join seminar_body_za_cislo as min_body on\n (akt_body.resitel_id = min_body.resitel_id and\n (akt_body.rocnik = min_body.rocnik and akt_body.cislo >= min_body.cislo)\n )\n group by akt_body.id, akt_body.cislo_id, akt_body.resitel_id, akt_body.body\n order by body_celkem desc;\n\ncreate view seminar_body_k_cislu_odjakziva as\n select\n akt_body.id as id,\n akt_body.cislo_id as cislo_id,\n akt_body.resitel_id as resitel_id,\n akt_body.body as body,\n sum(min_body.body) as body_celkem\n from\n seminar_body_za_cislo as akt_body\n inner join seminar_body_za_cislo as min_body on\n (akt_body.resitel_id = min_body.resitel_id and\n ((akt_body.rocnik = min_body.rocnik and akt_body.cislo >= min_body.cislo) or\n (akt_body.rocnik < min_body.rocnik)\n )\n )\n group by akt_body.id, akt_body.cislo_id, akt_body.resitel_id, akt_body.body\n order by body_celkem desc;\n\n", + sql=" + drop view seminar_body_k_cislu; + drop view seminar_body_za_cislo; + + create view seminar_body_za_cislo as + select + seminar_reseni.cislo_body_id || '-' || seminar_reseni.resitel_id as id, + seminar_reseni.cislo_body_id as cislo_id, + seminar_reseni.resitel_id as resitel_id, + seminar_cisla.cislo as cislo, + seminar_cisla.rocnik_id as rocnik_id, + seminar_rocniky.rocnik as rocnik, + seminar_cisla.verejna_vysledkovka as verejna_vysledkovka, + sum(seminar_reseni.body) as body + from + seminar_reseni + inner join seminar_cisla on seminar_reseni.cislo_body_id = seminar_cisla.id + inner join seminar_rocniky on seminar_cisla.rocnik_id = seminar_rocniky.id + group by seminar_reseni.cislo_body_id, seminar_reseni.resitel_id, seminar_cisla.cislo, + seminar_cisla.rocnik_id, seminar_rocniky.rocnik, seminar_cisla.verejna_vysledkovka + order by body desc; + + create view seminar_body_k_cislu_rocnik as + select + akt_body.id as id, + akt_body.cislo_id as cislo_id, + akt_body.resitel_id as resitel_id, + akt_body.body as body, + sum(min_body.body) as body_celkem + from + seminar_body_za_cislo as akt_body + inner join seminar_body_za_cislo as min_body on + (akt_body.resitel_id = min_body.resitel_id and + (akt_body.rocnik = min_body.rocnik and akt_body.cislo >= min_body.cislo) + ) + group by akt_body.id, akt_body.cislo_id, akt_body.resitel_id, akt_body.body + order by body_celkem desc; + + create view seminar_body_k_cislu_odjakziva as + select + akt_body.id as id, + akt_body.cislo_id as cislo_id, + akt_body.resitel_id as resitel_id, + akt_body.body as body, + sum(min_body.body) as body_celkem + from + seminar_body_za_cislo as akt_body + inner join seminar_body_za_cislo as min_body on + (akt_body.resitel_id = min_body.resitel_id and + ((akt_body.rocnik = min_body.rocnik and akt_body.cislo >= min_body.cislo) or + (akt_body.rocnik < min_body.rocnik) + ) + ) + group by akt_body.id, akt_body.cislo_id, akt_body.resitel_id, akt_body.body + order by body_celkem desc; + + ", ), migrations.RunSQL( - sql="\n\ndrop view seminar_body_k_cislu_rocnik;\ncreate view seminar_body_k_cislu_rocnik as\n select\n seminar_cisla.id || '-' || min_body.resitel_id as id,\n seminar_cisla.id as cislo_id,\n min_body.resitel_id as resitel_id,\n sum(min_body.body) as body\n from\n seminar_cisla\n inner join seminar_body_za_cislo as min_body on\n (min_body.rocnik_id = seminar_cisla.rocnik_id and seminar_cisla.cislo >= min_body.cislo)\n group by seminar_cisla.id, min_body.resitel_id\n order by body desc;\n\ndrop view seminar_body_k_cislu_odjakziva;\ncreate view seminar_body_k_cislu_odjakziva as\n select\n seminar_cisla.id || '-' || min_body.resitel_id as id,\n seminar_cisla.id as cislo_id,\n min_body.resitel_id as resitel_id,\n sum(min_body.body) as body\n from\n seminar_cisla\n inner join seminar_rocniky on\n (seminar_cisla.rocnik_id = seminar_rocniky.id)\n inner join seminar_body_za_cislo as min_body on\n (min_body.rocnik_id = seminar_cisla.rocnik_id and seminar_cisla.cislo >= min_body.cislo) or\n (min_body.rocnik < seminar_rocniky.rocnik)\n group by seminar_cisla.id, min_body.resitel_id\n order by body desc;\n", + sql=" + drop view seminar_body_k_cislu_rocnik; + create view seminar_body_k_cislu_rocnik as + select + seminar_cisla.id || '-' || min_body.resitel_id as id, + seminar_cisla.id as cislo_id, + min_body.resitel_id as resitel_id, + sum(min_body.body) as body + from + seminar_cisla + inner join seminar_body_za_cislo as min_body on + (min_body.rocnik_id = seminar_cisla.rocnik_id and seminar_cisla.cislo >= min_body.cislo) + group by seminar_cisla.id, min_body.resitel_id + order by body desc; + + drop view seminar_body_k_cislu_odjakziva; + create view seminar_body_k_cislu_odjakziva as + select + seminar_cisla.id || '-' || min_body.resitel_id as id, + seminar_cisla.id as cislo_id, + min_body.resitel_id as resitel_id, + sum(min_body.body) as body + from + seminar_cisla + inner join seminar_rocniky on + (seminar_cisla.rocnik_id = seminar_rocniky.id) + inner join seminar_body_za_cislo as min_body on + (min_body.rocnik_id = seminar_cisla.rocnik_id and seminar_cisla.cislo >= min_body.cislo) or + (min_body.rocnik < seminar_rocniky.rocnik) + group by seminar_cisla.id, min_body.resitel_id + order by body desc; + ", ), migrations.CreateModel( name='VysledkyCelkemKCislu', From 6a93c1c7bb4aa0905bd93ab0c0197ef1c7924fa0 Mon Sep 17 00:00:00 2001 From: Pavel 'LEdoian' Turinsky Date: Thu, 7 Nov 2019 21:05:55 +0100 Subject: [PATCH 3/4] =?UTF-8?q?Smazal=20jsem=20v=C5=A1echy=20v=C3=BDsledky?= =?UTF-8?q?=20a=20mo=C5=BEn=C3=A1=20jsem=20to=20nerozbil?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../0001_squashed_0067_auto_20190814_0805.py | 216 ------------------ 1 file changed, 216 deletions(-) diff --git a/seminar/migrations/0001_squashed_0067_auto_20190814_0805.py b/seminar/migrations/0001_squashed_0067_auto_20190814_0805.py index 3cc3be08..c1dc0c09 100644 --- a/seminar/migrations/0001_squashed_0067_auto_20190814_0805.py +++ b/seminar/migrations/0001_squashed_0067_auto_20190814_0805.py @@ -516,31 +516,6 @@ class Migration(migrations.Migration): ] operations = [ - migrations.CreateModel( - name='VysledkyKCislu', - fields=[ - ('dummy_id', models.CharField(db_column='id', max_length=32, primary_key=True, serialize=False, verbose_name='dummy ID pro view')), - ('body', models.IntegerField(db_column='body', verbose_name='body za číslo')), - ('body_celkem', models.IntegerField(db_column='body_celkem', verbose_name='body celkem do čísla')), - ], - options={ - 'abstract': False, - 'db_table': 'seminar_body_k_cislu', - 'managed': False, - }, - ), - migrations.CreateModel( - name='VysledkyZaCislo', - fields=[ - ('dummy_id', models.CharField(db_column='id', max_length=32, primary_key=True, serialize=False, verbose_name='dummy ID pro view')), - ('body', models.IntegerField(db_column='body', verbose_name='body za číslo')), - ], - options={ - 'abstract': False, - 'db_table': 'seminar_body_za_cislo', - 'managed': False, - }, - ), migrations.CreateModel( name='Cislo', fields=[ @@ -720,37 +695,6 @@ class Migration(migrations.Migration): name='rocnik', field=models.ForeignKey(on_delete=django.db.models.deletion.CASCADE, related_name='cisla', to='seminar.Rocnik', verbose_name='ročník'), ), - migrations.RunSQL( - sql=" - create view seminar_body_za_cislo as - select - sr.cislo_body_id || '-' || sr.resitel_id as id, - sr.cislo_body_id as cislo_id, - sr.resitel_id as resitel_id, - sum(sr.body) as body - from seminar_reseni as sr - group by sr.cislo_body_id, sr.resitel_id - order by body desc; - - create view seminar_body_k_cislu as - select - akt_c.id || '-' || min_bzc.resitel_id as id, - akt_c.id as cislo_id, - min_bzc.resitel_id as resitel_id, - max(akt_bzc.body) as body, - sum(min_bzc.body) as body_celkem - from ((seminar_cisla as akt_c - inner join seminar_cisla as min_c on min_c.rocnik_id = akt_c.rocnik_id and akt_c.cislo >= min_c.cislo) - inner join seminar_body_za_cislo as min_bzc on min_c.id = min_bzc.cislo_id) - left outer join seminar_body_za_cislo as akt_bzc on akt_bzc.cislo_id = akt_c.id and akt_bzc.resitel_id = min_bzc.resitel_id - group by akt_c.id, min_bzc.resitel_id, akt_bzc.resitel_id - order by body_celkem desc; - ", - reverse_sql=' - drop view seminar_body_k_cislu; - drop view seminar_body_za_cislo; - ', - ), migrations.AlterField( model_name='reseni', name='poznamka', @@ -969,9 +913,6 @@ class Migration(migrations.Migration): name='verejna_vysledkovka', field=models.BooleanField(default=False, help_text='Je-li false u veřejného čísla, není výsledkovka zatím veřejná.', verbose_name='zveřejněna výsledkovka'), ), - migrations.RunSQL( - sql='\ndrop view seminar_body_k_cislu;\ndrop view seminar_body_za_cislo;\n', - ), migrations.AlterField( model_name='problem', name='body', @@ -982,33 +923,6 @@ class Migration(migrations.Migration): name='body', field=models.DecimalField(blank=True, decimal_places=1, max_digits=8, null=True, verbose_name='body'), ), - migrations.RunSQL( - sql=" - create view seminar_body_za_cislo as - select - sr.cislo_body_id || '-' || sr.resitel_id as id, - sr.cislo_body_id as cislo_id, - sr.resitel_id as resitel_id, - sum(sr.body) as body - from seminar_reseni as sr - group by sr.cislo_body_id, sr.resitel_id - order by body desc; - - create view seminar_body_k_cislu as - select - akt_c.id || '-' || min_bzc.resitel_id as id, - akt_c.id as cislo_id, - min_bzc.resitel_id as resitel_id, - max(akt_bzc.body) as body, - sum(min_bzc.body) as body_celkem - from ((seminar_cisla as akt_c - inner join seminar_cisla as min_c on min_c.rocnik_id = akt_c.rocnik_id and akt_c.cislo >= min_c.cislo) - inner join seminar_body_za_cislo as min_bzc on min_c.id = min_bzc.cislo_id) - left outer join seminar_body_za_cislo as akt_bzc on akt_bzc.cislo_id = akt_c.id and akt_bzc.resitel_id = min_bzc.resitel_id - group by akt_c.id, min_bzc.resitel_id, akt_bzc.resitel_id - order by body_celkem desc; - ", - ), migrations.CreateModel( name='Novinky', fields=[ @@ -1057,136 +971,6 @@ class Migration(migrations.Migration): name='typ', field=models.CharField(choices=[(b'jarni', 'Jarní soustředění'), (b'podzimni', 'Podzimní soustředění'), (b'vikend', 'Víkendový sraz')], default=b'podzimni', max_length=16, verbose_name='typ akce'), ), - migrations.RunSQL( - sql=" - drop view seminar_body_k_cislu; - drop view seminar_body_za_cislo; - - create view seminar_body_za_cislo as - select - seminar_reseni.cislo_body_id || '-' || seminar_reseni.resitel_id as id, - seminar_reseni.cislo_body_id as cislo_id, - seminar_reseni.resitel_id as resitel_id, - seminar_cisla.cislo as cislo, - seminar_cisla.rocnik_id as rocnik_id, - seminar_rocniky.rocnik as rocnik, - seminar_cisla.verejna_vysledkovka as verejna_vysledkovka, - sum(seminar_reseni.body) as body - from - seminar_reseni - inner join seminar_cisla on seminar_reseni.cislo_body_id = seminar_cisla.id - inner join seminar_rocniky on seminar_cisla.rocnik_id = seminar_rocniky.id - group by seminar_reseni.cislo_body_id, seminar_reseni.resitel_id, seminar_cisla.cislo, - seminar_cisla.rocnik_id, seminar_rocniky.rocnik, seminar_cisla.verejna_vysledkovka - order by body desc; - - create view seminar_body_k_cislu_rocnik as - select - akt_body.id as id, - akt_body.cislo_id as cislo_id, - akt_body.resitel_id as resitel_id, - akt_body.body as body, - sum(min_body.body) as body_celkem - from - seminar_body_za_cislo as akt_body - inner join seminar_body_za_cislo as min_body on - (akt_body.resitel_id = min_body.resitel_id and - (akt_body.rocnik = min_body.rocnik and akt_body.cislo >= min_body.cislo) - ) - group by akt_body.id, akt_body.cislo_id, akt_body.resitel_id, akt_body.body - order by body_celkem desc; - - create view seminar_body_k_cislu_odjakziva as - select - akt_body.id as id, - akt_body.cislo_id as cislo_id, - akt_body.resitel_id as resitel_id, - akt_body.body as body, - sum(min_body.body) as body_celkem - from - seminar_body_za_cislo as akt_body - inner join seminar_body_za_cislo as min_body on - (akt_body.resitel_id = min_body.resitel_id and - ((akt_body.rocnik = min_body.rocnik and akt_body.cislo >= min_body.cislo) or - (akt_body.rocnik < min_body.rocnik) - ) - ) - group by akt_body.id, akt_body.cislo_id, akt_body.resitel_id, akt_body.body - order by body_celkem desc; - - ", - ), - migrations.RunSQL( - sql=" - drop view seminar_body_k_cislu_rocnik; - create view seminar_body_k_cislu_rocnik as - select - seminar_cisla.id || '-' || min_body.resitel_id as id, - seminar_cisla.id as cislo_id, - min_body.resitel_id as resitel_id, - sum(min_body.body) as body - from - seminar_cisla - inner join seminar_body_za_cislo as min_body on - (min_body.rocnik_id = seminar_cisla.rocnik_id and seminar_cisla.cislo >= min_body.cislo) - group by seminar_cisla.id, min_body.resitel_id - order by body desc; - - drop view seminar_body_k_cislu_odjakziva; - create view seminar_body_k_cislu_odjakziva as - select - seminar_cisla.id || '-' || min_body.resitel_id as id, - seminar_cisla.id as cislo_id, - min_body.resitel_id as resitel_id, - sum(min_body.body) as body - from - seminar_cisla - inner join seminar_rocniky on - (seminar_cisla.rocnik_id = seminar_rocniky.id) - inner join seminar_body_za_cislo as min_body on - (min_body.rocnik_id = seminar_cisla.rocnik_id and seminar_cisla.cislo >= min_body.cislo) or - (min_body.rocnik < seminar_rocniky.rocnik) - group by seminar_cisla.id, min_body.resitel_id - order by body desc; - ", - ), - migrations.CreateModel( - name='VysledkyCelkemKCislu', - fields=[ - ('dummy_id', models.CharField(db_column=b'id', max_length=32, primary_key=True, serialize=False, verbose_name='dummy ID pro view')), - ('body', models.DecimalField(db_column=b'body', decimal_places=1, max_digits=8, verbose_name='body za číslo')), - ('body_celkem', models.DecimalField(db_column=b'body_celkem', decimal_places=1, max_digits=8, verbose_name='body celkem do čísla včetně minulých ročníků')), - ], - options={ - 'abstract': False, - 'db_table': 'seminar_body_celkem_k_cislu', - 'managed': False, - }, - ), - migrations.CreateModel( - name='VysledkyKCisluOdjakziva', - fields=[ - ('dummy_id', models.CharField(db_column=b'id', max_length=32, primary_key=True, serialize=False, verbose_name='dummy ID pro view')), - ('body', models.DecimalField(db_column=b'body', decimal_places=1, max_digits=8, verbose_name='body za číslo')), - ], - options={ - 'abstract': False, - 'db_table': 'seminar_body_k_cislu_odjakziva', - 'managed': False, - }, - ), - migrations.CreateModel( - name='VysledkyKCisluZaRocnik', - fields=[ - ('dummy_id', models.CharField(db_column=b'id', max_length=32, primary_key=True, serialize=False, verbose_name='dummy ID pro view')), - ('body', models.DecimalField(db_column=b'body', decimal_places=1, max_digits=8, verbose_name='body za číslo')), - ], - options={ - 'abstract': False, - 'db_table': 'seminar_body_k_cislu_rocnik', - 'managed': False, - }, - ), migrations.AlterField( model_name='organizator', name='foto', From df4ae39a3f0ed098a81b0afeaaf83db78bf92b2e Mon Sep 17 00:00:00 2001 From: Pavel 'LEdoian' Turinsky Date: Thu, 7 Nov 2019 21:16:29 +0100 Subject: [PATCH 4/4] =?UTF-8?q?Django=20hraje=20squash=20=C5=A1patn=C4=9B,?= =?UTF-8?q?=20zapom=C3=ADn=C3=A1=20importovat?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- seminar/migrations/0001_squashed_0067_auto_20190814_0805.py | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/seminar/migrations/0001_squashed_0067_auto_20190814_0805.py b/seminar/migrations/0001_squashed_0067_auto_20190814_0805.py index c1dc0c09..287be0f1 100644 --- a/seminar/migrations/0001_squashed_0067_auto_20190814_0805.py +++ b/seminar/migrations/0001_squashed_0067_auto_20190814_0805.py @@ -10,6 +10,12 @@ import imagekit.models.fields import seminar.models import taggit.managers +# migr 0053 +import datetime as dt + +# migr 0058 +from django.db.models import Q + # Functions from the following migrations need manual copying. # Move them and any dependencies into this file, then update the