- {{ rv.poradi }}
- | {{ rv.resitel.titul }} MM {{ rv.resitel.plne_jmeno }}
+ | {% autoescape off %}{{ rv.poradi }}{% endautoescape %}
+ |
+ {% if rv.titul %}
+ {{ rv.titul }}MM
+ {% endif %}
+ {{ rv.resitel.plne_jmeno }}
| {{ rv.resitel.rocnik }}
| {{ rv.body_odjakziva }}
- {% for b in rv.body %}
+ {% for b in rv.body_cisla %}
| {{ b }}
{% endfor %}
| {{ rv.body_rocnik }}
diff --git a/seminar/templates/seminar/archiv/submenu.html b/seminar/templates/seminar/archiv/submenu.html
index fb0bd921..234a0f7c 100644
--- a/seminar/templates/seminar/archiv/submenu.html
+++ b/seminar/templates/seminar/archiv/submenu.html
@@ -1,9 +1,9 @@
{% with "/archiv" as cesta %}
{% endwith %}
diff --git a/seminar/templates/seminar/archiv/temata.html b/seminar/templates/seminar/archiv/temata.html
new file mode 100644
index 00000000..44e40ef2
--- /dev/null
+++ b/seminar/templates/seminar/archiv/temata.html
@@ -0,0 +1,23 @@
+{% extends "seminar/archiv/base_temata.html" %}
+
+{% block content %}
+
+ {% block nadpis1a %}{% block nadpis1b %}
+ Archiv témat
+ {% endblock %}{% endblock%}
+
+
+ {% for tema in object_list %}
+ {% with tema.cislo_zadani.rocnik.rocnik as rocnik %}
+ {% ifchanged rocnik %}
+ {% if not forloop.first %}{% endif %}
+ {{ rocnik }}. ročník
+
+
+{% endblock content %}
diff --git a/seminar/templates/seminar/clanky/base.html b/seminar/templates/seminar/clanky/base.html
index 8698808e..45c022aa 100644
--- a/seminar/templates/seminar/clanky/base.html
+++ b/seminar/templates/seminar/clanky/base.html
@@ -1,5 +1,7 @@
{% extends "base.html" %}
+{% block menu_clanky %}selected{% endblock %}
+
{% block submenu %}
{% include "seminar/clanky/submenu.html" %}
{% endblock %}
diff --git a/seminar/templates/seminar/clanky/submenu.html b/seminar/templates/seminar/clanky/submenu.html
index ee6ebcdc..e909c7f1 100644
--- a/seminar/templates/seminar/clanky/submenu.html
+++ b/seminar/templates/seminar/clanky/submenu.html
@@ -1,9 +1,9 @@
{% with "/clanky" as cesta %}
{% endwith %}
diff --git a/seminar/templates/seminar/cojemam/organizatori.html b/seminar/templates/seminar/cojemam/organizatori.html
index 2d2ab12f..f384dc10 100644
--- a/seminar/templates/seminar/cojemam/organizatori.html
+++ b/seminar/templates/seminar/cojemam/organizatori.html
@@ -1,22 +1,25 @@
{% extends "seminar/cojemam/base.html" %}
-{% block nadpis1 %}
+{% block nadpis1a %}{% block nadpis1b %}
{% if aktivni %}
Organizátoři
{% else %}
Vysloužilí organizátoři
{% endif %}
-{% endblock%}
+{% endblock%}{% endblock%}
+
+{% block menu_uvod %}selected{% endblock %}
+{% block submenu %}
+ {% with "org" as selected %}
+ {% include "seminar/cojemam/submenu.html" %}
+ {% endwith %}
+{% endblock %}
{% block content %}
+ {% if not aktivni %}
+ Aktivní organizátoři
+ {% endif %}
{% for org in object_list %}
-
{{org.user.first_name}}
{% if org.prezdivka %}
@@ -31,13 +34,13 @@
{% endif %}
- {#TODO časovat dle rodu #}
- {% if org.organizuje_od_roku %}
- - {% if aktivni %}Organizuje{% else %}Organizoval{% endif %} od roku {{org.organizuje_od_roku}}
- {% endif %}
- {% if org.organizuje_do_roku %}
-
- {% if aktivni %}Organizuje{% else %}Organizoval{% endif %} do roku {{org.organizuje_do_roku}}
- {% endif %}
+
-
+ {% if aktivni %}
+ Organizuje od roku {{org.organizuje_od_roku}}
+ {% else %}
+ {#TODO časovat dle rodu #}
+ Organizoval v letech {{org.organizuje_od_roku}}–{{org.organizuje_do_roku}}
+ {% endif %}
{% if org.studuje %}
- Studuje: {{org.studuje}}
{% endif %}
@@ -53,6 +56,8 @@
{% if aktivni%}
Vysloužilí organizátoři
+ {% else %}
+ Aktivní organizátoři
{% endif %}
diff --git a/seminar/templates/seminar/cojemam/submenu.html b/seminar/templates/seminar/cojemam/submenu.html
index f130e583..2fe62d2f 100644
--- a/seminar/templates/seminar/cojemam/submenu.html
+++ b/seminar/templates/seminar/cojemam/submenu.html
@@ -1,10 +1,10 @@
{% with "/co-je-MaM" as cesta %}
{% endwith %}
diff --git a/seminar/templates/seminar/novinky.html b/seminar/templates/seminar/novinky.html
index c3b2e3f6..9fc98570 100644
--- a/seminar/templates/seminar/novinky.html
+++ b/seminar/templates/seminar/novinky.html
@@ -1,15 +1,32 @@
-{% extends 'base.html' %}
-Před začátkem bloku.
-{% block body %}
-Tady bude začátek.
- {% for novinka in novinky %}
- {% if novinka.datum > pred_2_mesici and novinka.zverejneno %}
-
- Tady bude novinka.
- {{ novinka.text }}
-
-
- {% endif %}
- {% endfor%}
-Tady bude konec.
-{% endblock %}
+{% for novinka in object_list %}
+{# pripravene div-y na stylovani#}
+
+ {# datum #}
+ {{novinka.datum}}
+ {# text #}
+ {{ novinka.text | safe }}
+ {# obrazek #}
+ {% if novinka.obrazek %}
+
+
+
+ {% endif %}
+ {# autor #}
+ {% if user.is_staff %}
+ {{novinka.autor.first_name}}
+ {% if novinka.autor.organizator.prezdivka%}
+ „{{novinka.autor.organizator.prezdivka}}“
+ {% endif %}
+ {{novinka.autor.last_name}}
+
+ {% endif %}
+
+{% endfor%}
+
diff --git a/seminar/templates/seminar/pracuje_se.html b/seminar/templates/seminar/pracuje_se.html
index f79d3ee3..5349707d 100644
--- a/seminar/templates/seminar/pracuje_se.html
+++ b/seminar/templates/seminar/pracuje_se.html
@@ -1,7 +1,12 @@
{% load staticfiles %}
{% block content %}
- {% block nadpis1 %}Tady se pracuje{% endblock%}
+
+ {% block nadpis1a %}{% block nadpis1b %}
+ Tady se pracuje
+ {% endblock %}{% endblock %}
+
+
Na této stránce velmi intenzivně pracujeme.
Za dočasnou nedostupnost se omlouváme.
diff --git a/seminar/templates/seminar/soustredeni/seznam_soustredeni.html b/seminar/templates/seminar/soustredeni/seznam_soustredeni.html
index 42d50db5..a6c07ea0 100644
--- a/seminar/templates/seminar/soustredeni/seznam_soustredeni.html
+++ b/seminar/templates/seminar/soustredeni/seznam_soustredeni.html
@@ -1,8 +1,19 @@
{% extends "seminar/soustredeni/base.html" %}
+{% block menu_soustredeni %}selected{% endblock %}
+{% block submenu %}
+ {% with "probehlo" as selected %}
+ {% include "seminar/soustredeni/submenu.html" %}
+ {% endwith %}
+{% endblock submenu %}
+
{% block content %}{% if user.is_authenticated %}{# PRACUJE SE STRANKA #}
- {% block nadpis1 %}Soustředění{% endblock %}
+
+ {% block nadpis1a %}{% block nadpis1b %}
+ Soustředění
+ {% endblock %}{% endblock %}
+
{# Projdi vsechna soustredeni #}
{% for soustredeni in object_list %}
diff --git a/seminar/templates/seminar/soustredeni/submenu.html b/seminar/templates/seminar/soustredeni/submenu.html
index c1e9deed..d3ef4b18 100644
--- a/seminar/templates/seminar/soustredeni/submenu.html
+++ b/seminar/templates/seminar/soustredeni/submenu.html
@@ -1,9 +1,9 @@
{% with "/soustredeni" as cesta %}
{% endwith %}
diff --git a/seminar/templates/seminar/stare_novinky.html b/seminar/templates/seminar/stare_novinky.html
new file mode 100644
index 00000000..821889bf
--- /dev/null
+++ b/seminar/templates/seminar/stare_novinky.html
@@ -0,0 +1,13 @@
+{% extends 'base.html' %}
+
+{% block content %}
+
+
+ {% block nadpis1a %}{% block nadpis1b %}
+ Archiv novinek
+ {% endblock %}{% endblock %}
+
+
+ {% include 'seminar/novinky.html' %}
+
+{% endblock %}
diff --git a/seminar/templates/seminar/stav_databaze.html b/seminar/templates/seminar/stav_databaze.html
index 5c04b9a5..a8170290 100644
--- a/seminar/templates/seminar/stav_databaze.html
+++ b/seminar/templates/seminar/stav_databaze.html
@@ -2,7 +2,11 @@
{% block content %}
- {% block nadpis1 %}Stav databáze{% endblock %}
+
+ {% block nadpis1a %}{% block nadpis1b %}
+ Stav databáze
+ {% endblock %}{% endblock %}
+
Řešitelé
diff --git a/seminar/templates/seminar/titulnistrana.html b/seminar/templates/seminar/titulnistrana.html
index 424efdee..584668db 100644
--- a/seminar/templates/seminar/titulnistrana.html
+++ b/seminar/templates/seminar/titulnistrana.html
@@ -1,8 +1,20 @@
-Trala!
{% extends 'base.html' %}
-HU!
-{% block novinky %}
- Tady bude nadpis pro novinky.
- {% include 'novinky.html' %}
+
+{% block content %}
+
+ {# Uvitaci text #}
+
+ {% block nadpis1a %}{% block nadpis1b %}
+ Tož vitajte!
+ {% endblock %}{% endblock %}
+
+ Uvítací text či-co.
+
+ {# Novinky #}
+ Novinky
+ {% include 'seminar/novinky.html' %}
+
+ Archiv novinek
+
{% endblock %}
diff --git a/seminar/templates/seminar/zadani/AktualniZadani.html b/seminar/templates/seminar/zadani/AktualniZadani.html
index ae2dfd60..2bda6387 100644
--- a/seminar/templates/seminar/zadani/AktualniZadani.html
+++ b/seminar/templates/seminar/zadani/AktualniZadani.html
@@ -1,8 +1,19 @@
{% extends "seminar/zadani/base.html" %}
+{% block submenu %}
+ {% with "aktualni" as selected %}
+ {% include 'seminar/zadani/submenu.html' %}
+ {% endwith %}
+{% endblock submenu %}
+
{% block content %}
- {% block nadpis1 %}Aktuální zadání{% endblock %}
+
+ {% block nadpis1a %}{% block nadpis1b %}
+ Aktuální zadání
+ {% endblock %}{% endblock %}
+
+
{% with nastaveni.aktualni_cislo as ac %}
{% if ac.zadane_problemy.all %}
@@ -18,9 +29,7 @@
{# publikace jednotlivych zadani #}
{% for problem in sada %}
{# TODO použít {{problem.kod_v_rocniku}} ? vrací 4.u1 místo 4.1 #}
- {{problem.cislo_zadani.cislo}}.{{problem.kod}} {{problem.nazev}}
- {# nezobrazuj body, pokud nejsou zadane #}
- {% if problem.body %}({{problem.body}}b){% endif %}
+ {{problem.cislo_zadani.cislo}}.{{problem.kod}} {{problem.nazev}} {{ problem.body_v_zavorce }}
{% autoescape off %}{{problem.text_zadani}}{% endautoescape %}
{% endfor %}
@@ -28,12 +37,7 @@
Aktuálně nejsou zadané žádné úlohy k řešení.
{% endfor %}
- Témata
- {% for tema in temata %}
- Téma {{tema.kod}}: {{tema.nazev}}
- Stránka tématu
- {% autoescape off %}{{tema.text_zadani}}{% endautoescape %}
- {% endfor %}
+ Témata
{% endwith %}
diff --git a/seminar/templates/seminar/zadani/Temata.html b/seminar/templates/seminar/zadani/Temata.html
index 14a59d5e..87aa8e33 100644
--- a/seminar/templates/seminar/zadani/Temata.html
+++ b/seminar/templates/seminar/zadani/Temata.html
@@ -1,26 +1,38 @@
{% extends "seminar/zadani/base.html" %}
+{% block submenu %}
+ {% with "temata" as selected %}
+ {% include 'seminar/zadani/submenu.html' %}
+ {% endwith %}
+{% endblock submenu %}
+
+
{% block content %}
{% with nastaveni.aktualni_rocnik as ar %}
- {% block nadpis1 %}Témata{% endblock %}
+
+ {% block nadpis1a %}{% block nadpis1b %}
+ Témata
+ {% endblock %}{% endblock %}
+
+
+
+ Témata jsou hlavním obsahem časopisu M&M. Obvykle představují
+ složitější a obecnější problémy než samostatné úlohy. Navíc je v jejich
+ zadání vždy prostor pro tvůrčí rozšíření. Za pěkný článek k tématu lze
+ získat třeba i 20 bodů, určitě se tedy vyplatí se tématy zabývat.
+
- Témata obvykle představují složitější problémy, než samostatné úlohy. Navíc
- v jejich zadání je vždy prostor pro tvůrčí rozšíření. Nad nápady
- k tématům můžeš přemýšlet celý rok až do termínu odeslání šestého
- čísla. Pokud tě něco napadne, napiš nám o tom článek. My došlé články
- revidujeme, hodnotíme a ty nejzajímavější uveřejňujeme zde na webu,
- případně i v někerém z čísel časopisu. Můžeš také reagovat na
- články ostatních řešitelů. Za pěkný článek k tématu lze získat třeba i
- 20 bodů, určitě se tedy vyplatí jimi zabývat. Pokud nevíš, jak takový
- článek napsat, podívej se na náš návod.{# TODO odkaz #}
+ Jak řešit téma?
+ {% if temata %}
Letos jsme pro tebe připravili tato témata:
+ {% endif %}
{% for problem in temata %}
{# TODO použít {{problem.kod_v_rocniku}} ? vrací t4 místo 4 #}
- Téma {{problem.kod}}: {{problem.nazev}}
+ Téma {{problem.kod}}: {{problem.nazev}}
{% autoescape off %}{{problem.text_zadani}}{% endautoescape %}
{% empty %}
diff --git a/seminar/templates/seminar/zadani/base.html b/seminar/templates/seminar/zadani/base.html
index ba4148aa..043fe401 100644
--- a/seminar/templates/seminar/zadani/base.html
+++ b/seminar/templates/seminar/zadani/base.html
@@ -1,5 +1,7 @@
{% extends "base.html" %}
+{% block menu_zadani %}selected{% endblock %}
+
{% block submenu %}
{% include 'seminar/zadani/submenu.html' %}
{% endblock submenu %}
diff --git a/seminar/templates/seminar/zadani/submenu.html b/seminar/templates/seminar/zadani/submenu.html
index 92c10be5..1ff532ab 100644
--- a/seminar/templates/seminar/zadani/submenu.html
+++ b/seminar/templates/seminar/zadani/submenu.html
@@ -1,11 +1,11 @@
{% with "/zadani" as cesta %}
{% endwith %}
diff --git a/seminar/urls.py b/seminar/urls.py
index a64127d6..ff322241 100644
--- a/seminar/urls.py
+++ b/seminar/urls.py
@@ -7,18 +7,20 @@ urlpatterns = patterns('',
url(r'^co-je-MaM/organizatori/organizovali/$', views.CojemamOrganizatoriStariView.as_view(), name='stari_organizatori'),
url(r'^archiv/cisla/$', views.CislaView.as_view()),
+ url(r'^archiv/temata/$', views.ArchivTemataView.as_view()),
url(r'^rocnik/(?P \d+)/$', views.RocnikView.as_view(), name='seminar_rocnik'),
url(r'^cislo/(?P\d+)\.(?P[0-9-]+)/$', views.CisloView.as_view(), name='seminar_cislo'),
url(r'^problem/(?P\d+)/$', views.ProblemView.as_view(), name='seminar_problem'),
- url(r'^soustredeni/$', views.SoustredeniListView.as_view(),
+ url(r'^soustredeni/probehlo/$', views.SoustredeniListView.as_view(),
name = 'seminar_seznam_soustredeni'),
url(r'^soustredeni/(?P\d+)/$', views.SoustredeniView.as_view(), name='seminar_soustredeni'),
url(r'^zadani/aktualni/$', views.AktualniZadaniView, name='seminar_aktualni_zadani'),
- url(r'^zadani/temata/$', views.TemataView, name='seminar_temata'),
+ url(r'^zadani/temata/$', views.ZadaniTemataView, name='seminar_temata'),
url(r'^$', views.TitulniStranaView.as_view(), name='titulni_strana'),
+ url(r'^stare-novinky/$', views.StareNovinkyView.as_view(), name='stare_novinky'),
url(r'^stav$', views.StavDatabazeView, name='stav_databaze'),
diff --git a/seminar/views.py b/seminar/views.py
index cb8d4f20..4eaf8f19 100644
--- a/seminar/views.py
+++ b/seminar/views.py
@@ -11,15 +11,16 @@ from .models import Problem, Cislo, Reseni, Nastaveni, Rocnik, Soustredeni, Orga
from .models import VysledkyZaCislo, VysledkyKCisluZaRocnik, VysledkyKCisluOdjakziva
from . import utils
-import datetime
+from datetime import timedelta, date
+from itertools import groupby
def AktualniZadaniView(request):
nastaveni = get_object_or_404(Nastaveni)
problemy = Problem.objects.filter(cislo_zadani=nastaveni.aktualni_cislo).filter(stav = 'zadany')
- ulohy = problemy.filter(typ = 'uloha')
- serialy = problemy.filter(typ = 'serial')
- temata = problemy.filter(typ = 'tema')
+ ulohy = problemy.filter(typ = 'uloha').order_by('kod')
+ serialy = problemy.filter(typ = 'serial').order_by('kod')
+ temata = problemy.filter(typ = 'tema').order_by('kod')
jednorazove_problemy = [ulohy, serialy]
return render(request, 'seminar/zadani/AktualniZadani.html',
{'nastaveni': nastaveni,
@@ -28,11 +29,11 @@ def AktualniZadaniView(request):
},
)
-def TemataView(request):
+def ZadaniTemataView(request):
nastaveni = get_object_or_404(Nastaveni)
return render(request, 'seminar/zadani/Temata.html',
{
- 'temata': Problem.objects.filter(typ=Problem.TYP_TEMA, cislo_zadani__rocnik=nastaveni.aktualni_rocnik),
+ 'temata': Problem.objects.filter(typ=Problem.TYP_TEMA, stav=Problem.STAV_ZADANY, cislo_zadani__rocnik=nastaveni.aktualni_rocnik).order_by('kod'),
}
)
@@ -40,19 +41,17 @@ def TemataView(request):
class TitulniStranaView(generic.ListView):
model = Novinky
- template_name='seminar/novinky.html'
+ template_name='seminar/titulnistrana.html'
+ queryset = Novinky.objects.filter(zverejneno=True).order_by('-datum')[:5]
- def get_context_data(self, **kwargs):
- context = super(TitulniStranaView, self).get_context_data(**kwargs)
- context['pred_2_mesici'] = (datetime.date.today() - datetime.timedelta(2*365/12)).isoformat()
- #ulozi datum pred dvema mesici
- #elegantneji mozne pomoci dateutil:
- '''
- from dateutil.relativedelta import relativedelta
-
- date.today() + relativedelta(month=-2)
- '''
- return context
+ #def get_context_data(self, **kwargs):
+ # context = super(TitulniStranaView, self).get_context_data(**kwargs)
+ # return context
+
+class StareNovinkyView(generic.ListView):
+ model = Novinky
+ template_name = 'seminar/stare_novinky.html'
+ queryset = Novinky.objects.filter(zverejneno=True).order_by('-datum')
### Co je M&M
@@ -61,7 +60,7 @@ class TitulniStranaView(generic.ListView):
class CojemamOrganizatoriView(generic.ListView):
model = Organizator
template_name='seminar/cojemam/organizatori.html'
- queryset = Organizator.objects.filter(user__is_active=True).order_by('user__first_name')
+ queryset = Organizator.objects.exclude(organizuje_do_roku__isnull=False, organizuje_do_roku__lt=date.today().year).order_by('user__first_name')
def get_context_data(self, **kwargs):
context = super(CojemamOrganizatoriView, self).get_context_data(**kwargs)
context['aktivni'] = True
@@ -70,7 +69,7 @@ class CojemamOrganizatoriView(generic.ListView):
class CojemamOrganizatoriStariView(generic.ListView):
model = Organizator
template_name='seminar/cojemam/organizatori.html'
- queryset = Organizator.objects.filter(user__is_active=False)
+ queryset = Organizator.objects.filter(organizuje_do_roku__isnull=False, organizuje_do_roku__lt=date.today().year).order_by('-organizuje_do_roku')
### Archiv
@@ -78,6 +77,26 @@ class CislaView(generic.ListView):
model = Rocnik
template_name='seminar/archiv/cisla.html'
+
+def sloupec_s_poradim(vysledky):
+ # počet řešitelů ve výsledkovce nad aktuálním
+ lepsich_resitelu = 0
+
+ poradi_l = []
+ # projdeme skupiny řešitelů se stejným počtem bodů
+ for skupina in (list(x) for _, x in groupby(vysledky, lambda x: x.body)):
+
+ # připravíme si obsahy buněk ve sloupci pořadí pro skupinu
+ if len(skupina) == 1:
+ poradi_l += ["{}.".format(lepsich_resitelu + 1)]
+ # je-li účastníků se stejným počtem bodů víc, pořadí (rozsah X.-Y.) je jen u prvního
+ else:
+ poradi_l += ["{}.–{}.".format(lepsich_resitelu + 1, lepsich_resitelu + len(skupina))] + [""] * (len(skupina)-1)
+ lepsich_resitelu += len(skupina)
+
+ return poradi_l
+
+
class RocnikView(generic.DetailView):
model = Rocnik
template_name = 'seminar/archiv/rocnik.html'
@@ -99,73 +118,45 @@ class RocnikView(generic.DetailView):
def get_context_data(self, **kwargs):
context = super(RocnikView, self).get_context_data(**kwargs)
- cisla_v_rocniku = VysledkyKCisluZaRocnik.objects.filter(cislo__verejna_vysledkovka = True).filter(cislo__rocnik = context['rocnik']).order_by('-cislo')
+ cisla_v_rocniku = VysledkyKCisluZaRocnik.objects.filter(cislo__verejna_vysledkovka = True).filter(cislo__rocnik = context['rocnik']).order_by('cislo')
#vyberu vsechny verejne vysledky z rocniku
#pokud žádné nejsou, výsledkovka se nezobrazí
if cisla_v_rocniku:
- vysledky = cisla_v_rocniku.filter(cislo = cisla_v_rocniku[0].cislo).order_by('-body', 'resitel__prijmeni', 'resitel__jmeno').select_related('resitel')
+ vysledky = list(cisla_v_rocniku.filter(cislo = cisla_v_rocniku[0].cislo).order_by('-body', 'resitel__prijmeni', 'resitel__jmeno').select_related('resitel'))
#vybere vsechny vysledky z posledniho verejneho cisla a setridi sestupne dle bodu
- vysledky_resitele = {}
- stejne_body = {}
- konec_rozmezi = {}
vysledkovka = []
- posledni_body = 100000
- predchozi_poradi = None
- body_minule = None
-
- for vi in range(len(vysledky)):
- v = vysledky[vi]
- rv = RadekVysledkovky()
- rv.resitel = v.resitel
+
+ # doplníme některé údaje do řádků výsledkovky pro řešitele ve skupině
+ for poradi, v in zip(sloupec_s_poradim(vysledky), vysledky):
+ v.poradi = poradi
+ v.resitel.rocnik = v.resitel.rocnik(context['rocnik'])
+
verejne_vysl_odjakziva = VysledkyKCisluOdjakziva.objects.filter(cislo__verejna_vysledkovka = True).filter(cislo__rocnik = context['rocnik']).filter(cislo = cisla_v_rocniku[0].cislo)
- rv.body_odjakziva = verejne_vysl_odjakziva.filter(resitel = rv.resitel)[0].body
- rv.resitel.titul = rv.resitel.get_titul(rv.body_odjakziva)
- rv.resitel.rocnik = rv.resitel.rocnik(context['rocnik'])
- rv.body = []*len(context['rocnik'].verejna_cisla())
+
+ v.body_odjakziva = verejne_vysl_odjakziva.filter(resitel = v.resitel)[0].body
+ v.titul = v.resitel.get_titul(v.body_odjakziva)
+ v.body_rocnik = v.body
+ v.body_cisla = []
+
#pokud pro dany rok a cislo nema resitel vysledky, ma defaultne 0
for cis in context['rocnik'].verejna_cisla():
if cis.verejna_vysledkovka:
- print cis
- body_za_cislo = VysledkyZaCislo.objects.filter(cislo__rocnik = context['rocnik']).filter(cislo = cis).filter(resitel = rv.resitel)
+ body_za_cislo = VysledkyZaCislo.objects.filter(cislo__rocnik = context['rocnik']).filter(cislo = cis).filter(resitel = v.resitel)
#seznam vysledku se spravnym rocnikem a cislem pro resitele
#zobrazim jen je-li vysledkovka verejna
if body_za_cislo:
- rv.body.append(body_za_cislo[0].body)
+ v.body_cisla.append(body_za_cislo[0].body)
#neprazdne vysledky by mely obsahovat prave jeden vysledek
else:
- rv.body.append(0)
+ v.body_cisla.append(0)
#resitel nema za cislo body
- rv.poradi = ''
- #defaultni poradi je prazdne - kvuli sdilenym mistum
- rv.body_rocnik = v.body
- rv.body_na_zacatku = rv.body_odjakziva - rv.body_rocnik
- #body za minule rocniky
- if posledni_body > v.body:
- if stejne_body.get(posledni_body):
- #pokud uz jsme predtim narazili na stejny pocet bodu
- konec_rozmezi[posledni_body] = int(predchozi_poradi.poradi) + stejne_body[posledni_body]
- #druha hranice sdilenych pozic - zacatek + pocet lidi se stejnymi body
- predchozi_poradi.poradi = '{0}. -- {1}.'.format(predchozi_poradi.poradi,konec_rozmezi[posledni_body])
- #predchozi radek ktery menil pocty bodu bude mit rozsah, pokud bylo vice radku se stejnym poctem bodu
- elif predchozi_poradi :
- predchozi_poradi.poradi = '{0}.'.format(predchozi_poradi.poradi)
- #pokud nebyl rozsah hodnot, vypisu, pridam tecku za cislo
- posledni_body = v.body
- rv.poradi = vi + 1
- #poradi se meni jen u resitele s rozdilnym poctem bodu nez mel minuly
- predchozi_poradi = rv
- elif posledni_body == v.body:
- if not stejne_body.get(v.body):
- stejne_body[v.body] = 1
- #pokud klic neexistuje, zalozim novy pro tohoto resitele
- else:
- stejne_body[v.body] += 1
- #rozsirim pocet resitelu sdilejici stejnou pozici
- vysledky_resitele[v.resitel.id] = rv
- #odkaz na radek vysledkovky patrici danemu resiteli
- vysledkovka.append(rv)
+
+ vysledkovka.append(v)
+
+ temata_v_rocniku = Problem.objects.filter(typ=Problem.TYP_TEMA, cislo_zadani__rocnik=context['rocnik'])
context['vysledkovka'] = vysledkovka
+ context['temata_v_rocniku'] = temata_v_rocniku
return context
class ProblemView(generic.DetailView):
@@ -194,6 +185,7 @@ class CisloView(generic.DetailView):
{'verbose_name': queryset.model._meta.verbose_name})
return obj
+
def get_context_data(self, **kwargs):
context = super(CisloView, self).get_context_data(**kwargs)
@@ -206,7 +198,7 @@ class CisloView(generic.DetailView):
resene_problemy = Problem.objects.filter(cislo_reseni=context['cislo']).filter(typ__in=typy_skutecne_zadanych).order_by('cislo_reseni__cislo', 'kod')
- problemy = sorted(list(set([r.problem for r in reseni])), key=lambda x:(0 if x.typ==Problem.TYP_ULOHA else 1,x.kod))
+ problemy = sorted(list(set([r.problem for r in reseni])), key=lambda x:(0 if x.typ==Problem.TYP_ULOHA else 1, x.kod_v_rocniku))
#setridi problemy podle typu a poradi zadani
problem_index = {}
for i in range(len(problemy)):
@@ -214,66 +206,42 @@ class CisloView(generic.DetailView):
#umoznuje zjistit index podle id problemu
vysledky_resitele = {}
- stejne_body = {}
- konec_rozmezi = {}
vysledkovka = []
- posledni_body = 100000
- predchozi_poradi = None
- body_minule = None
-
- for vi in range(len(vysledky)):
- v = vysledky[vi]
- tv = RadekVysledkovky()
- tv.resitel = v.resitel
- tv.resitel.titul = tv.resitel.get_titul(v.body)
- tv.rocnik = tv.resitel.rocnik(context['cislo'].rocnik)
- tv.vysledek = v
- #odkazuje na VysledkyKCislu
- tv.body = ['']*len(problemy)
- #pole bodu za ulohy
- tv.poradi = ''
- #defaultni poradi je prazdne - kvuli sdilenym mistum
- tv.body_celkem_rocnik = v.body
- tv.body_celkem_odjakziva = VysledkyKCisluOdjakziva.objects.get(resitel=v.resitel, cislo=context['cislo']).body
+
+ # doplníme některé údaje do řádků výsledkovky pro řešitele ve skupině
+ for poradi, v in zip(sloupec_s_poradim(vysledky), vysledky):
+ v.poradi = poradi
+ v.body_celkem_rocnik = v.body
+ v.body_celkem_odjakziva = VysledkyKCisluOdjakziva.objects.get(resitel=v.resitel, cislo=context['cislo']).body
+
+ # je tady '', aby se nezobrazovala 0, pokud se řešitel o řešení úlohy ani nepokusil
+ v.body_ulohy = [''] * len(problemy)
+
+ v.titul = v.resitel.get_titul(v.body_celkem_odjakziva)
+
body_cislo_q = VysledkyZaCislo.objects.filter(resitel=v.resitel, cislo=context['cislo'])
- tv.body_cislo = body_cislo_q[0].body if len(body_cislo_q) > 0 else 0
- tv.body_minule = tv.body_celkem_rocnik - tv.body_cislo
- tv.titul=tv.resitel.get_titul(int(tv.body_celkem_odjakziva))
- #pocet bodu do tohoto cisla
- if posledni_body > tv.body_celkem_rocnik:
- if stejne_body.get(posledni_body):
- konec_rozmezi[posledni_body] = int(predchozi_poradi.poradi) + stejne_body[posledni_body]
- #druha hranice sdilenych pozic - zacatek + pocet lidi se stejnymi body
- predchozi_poradi.poradi = '{0}. -- {1}.'.format(predchozi_poradi.poradi,konec_rozmezi[posledni_body])
- #predchozi radek ktery menil pocty bodu bude mit rozsah, pokud bylo vice radku se stejnym poctem bodu
- elif predchozi_poradi :
- predchozi_poradi.poradi = '{0}.'.format(predchozi_poradi.poradi)
- #pokud nebyl rozsah hodnot, pridam tecku za cislo
- posledni_body = tv.body_celkem_rocnik
- tv.poradi = vi + 1
- #poradi se meni jen u resitele s rozdilnym poctem bodu nez mel minuly
- predchozi_poradi = tv
- elif posledni_body == tv.body_celkem_rocnik:
- if not stejne_body.get(tv.body_celkem_rocnik):
- stejne_body[tv.body_celkem_rocnik] = 1
- #pokud klic neexistuje, zalozim novy pro tohoto resitele
- else:
- stejne_body[tv.body_celkem_rocnik] += 1
- #rozsirim pocet resitelu sdilejici stejnou pozici
- vysledky_resitele[v.resitel.id] = tv
- #odkaz na radek vysledkovky patrici danemu resiteli
- vysledkovka.append(tv)
+ v.body_cislo = body_cislo_q[0].body if body_cislo_q else 0
- for r in reseni:
- vysledky_resitele[r.resitel.id].body[problem_index[r.problem.id]] = r.body
-
+ vysledkovka.append(v)
+
+ # připravíme si odkaz na řádek, abychom do něj mohli doplnit body za jednotlivé úlohy
+ vysledky_resitele[v.resitel.id] = v
+ # za každé řešení doplníme k příslušnému řešiteli a úloze body
+ for r in reseni:
+ vysledky_resitele[r.resitel.id].body_ulohy[problem_index[r.problem.id]] = r.body
+
context['vysledkovka'] = vysledkovka
context['problemy'] = problemy
context['v_cisle_zadane'] = v_cisle_zadane
context['resene_problemy'] = resene_problemy
return context
+class ArchivTemataView(generic.ListView):
+ model = Problem
+ template_name = 'seminar/archiv/temata.html'
+ queryset = Problem.objects.filter(typ=Problem.TYP_TEMA, stav=Problem.STAV_ZADANY).select_related('cislo_zadani__rocnik__rocnik').order_by('-cislo_zadani__rocnik__rocnik', 'kod')
+
### Generovani vysledkovky
class CisloVysledkovkaView(CisloView):
|