|
@ -27,6 +27,7 @@ import seminar.forms as f |
|
|
from datetime import timedelta, date, datetime |
|
|
from datetime import timedelta, date, datetime |
|
|
from django.utils import timezone |
|
|
from django.utils import timezone |
|
|
from itertools import groupby |
|
|
from itertools import groupby |
|
|
|
|
|
from collections import OrderedDict |
|
|
import tempfile |
|
|
import tempfile |
|
|
import subprocess |
|
|
import subprocess |
|
|
import shutil |
|
|
import shutil |
|
@ -777,7 +778,28 @@ class CisloView(generic.DetailView): |
|
|
class ArchivTemataView(generic.ListView): |
|
|
class ArchivTemataView(generic.ListView): |
|
|
model = Problem |
|
|
model = Problem |
|
|
template_name = 'seminar/archiv/temata.html' |
|
|
template_name = 'seminar/archiv/temata.html' |
|
|
queryset = Tema.objects.filter(stav=Problem.STAV_ZADANY).select_related('cislo_zadani__rocnik').order_by('-cislo_zadani__rocnik__rocnik', 'kod') |
|
|
queryset = Tema.objects.filter(stav=Problem.STAV_ZADANY).select_related('rocnik').order_by('-rocnik', 'kod') |
|
|
|
|
|
|
|
|
|
|
|
def get_context_data(self, *args, **kwargs): |
|
|
|
|
|
ctx = super().get_context_data(*args, **kwargs) |
|
|
|
|
|
# Najdeme, jaké ročníky mají témata |
|
|
|
|
|
# TODO: Tohle by se rovnou mohlo tahat z databáze, ne? |
|
|
|
|
|
# Navíc už asi nepotřebuji ten select_related, že? |
|
|
|
|
|
rocniky_set = set() |
|
|
|
|
|
for tema in ctx['object_list']: |
|
|
|
|
|
rocniky_set.add(tema.rocnik) |
|
|
|
|
|
rocniky = list(rocniky_set) |
|
|
|
|
|
rocniky.sort(key=lambda r: int(r.rocnik), reverse=True) |
|
|
|
|
|
|
|
|
|
|
|
# Přiřadíme témátka k ročníkům |
|
|
|
|
|
# TODO: Asi taky jde udělat nějak elegantněji, ne? |
|
|
|
|
|
ctx['rocniky'] = OrderedDict() |
|
|
|
|
|
for rocnik in rocniky: |
|
|
|
|
|
ctx['rocniky'][rocnik] = [] |
|
|
|
|
|
for tema in ctx['object_list']: |
|
|
|
|
|
if tema.rocnik == rocnik: |
|
|
|
|
|
ctx['rocniky'][rocnik].append(tema) |
|
|
|
|
|
return ctx |
|
|
|
|
|
|
|
|
### Generovani vysledkovky |
|
|
### Generovani vysledkovky |
|
|
|
|
|
|
|
|