|
|
|
"""
|
|
|
|
Stránky, které se mi nepovedlo lépe zařadit.
|
|
|
|
|
|
|
|
Oproti `./pomocne.py` se tyto views používají přímo ve various
|
|
|
|
a naopak importují spoustu věcí odjinud
|
|
|
|
"""
|
|
|
|
|
|
|
|
from django.shortcuts import get_object_or_404, render
|
|
|
|
from django.utils import timezone
|
|
|
|
from django.views import generic
|
|
|
|
|
|
|
|
import novinky.views
|
|
|
|
import seminar.utils
|
|
|
|
import tvorba.views
|
|
|
|
from personalni.models import Resitel
|
|
|
|
from seminar import models as m
|
|
|
|
|
|
|
|
from ..models import Nastaveni
|
|
|
|
|
|
|
|
|
|
|
|
class TitulniStranaView(generic.ListView):
|
|
|
|
template_name = 'various/titulnistrana/titulnistrana.html'
|
|
|
|
|
|
|
|
def get_queryset(self):
|
|
|
|
return novinky.views.spravne_novinky(self.request)[:3]
|
|
|
|
|
|
|
|
def get_context_data(self, **kwargs):
|
|
|
|
context = super(TitulniStranaView, self).get_context_data(**kwargs)
|
|
|
|
nastaveni = get_object_or_404(Nastaveni)
|
|
|
|
|
|
|
|
deadline = m.Deadline.objects.filter(
|
|
|
|
deadline__gte=timezone.now()).order_by("deadline").first()
|
|
|
|
context['nejblizsi_deadline'] = deadline
|
|
|
|
|
|
|
|
# Aktuální témata
|
|
|
|
nazvy_a_odkazy_na_aktualni_temata = []
|
|
|
|
akt_temata = tvorba.views.aktualni_temata(nastaveni.aktualni_rocnik)
|
|
|
|
|
|
|
|
for tema in akt_temata:
|
|
|
|
# FIXME: netuším, jestli funguje tema.verejne_url(), nemáme testdata na témátka - je to asi url vzhledem k ročníku
|
|
|
|
nazvy_a_odkazy_na_aktualni_temata.append({
|
|
|
|
'nazev': tema.nazev,
|
|
|
|
'url': tema.verejne_url()
|
|
|
|
})
|
|
|
|
|
|
|
|
context['aktualni_temata'] = nazvy_a_odkazy_na_aktualni_temata
|
|
|
|
|
|
|
|
return context
|
|
|
|
|
|
|
|
|
|
|
|
class JakResitView(generic.ListView):
|
|
|
|
template_name = 'various/jakresit/jak-resit.html'
|
|
|
|
|
|
|
|
def get_queryset(self):
|
|
|
|
return None
|
|
|
|
|
|
|
|
|
|
|
|
### Status
|
|
|
|
def StavDatabazeView(request):
|
|
|
|
# nastaveni = Nastaveni.objects.get()
|
|
|
|
problemy = seminar.utils.seznam_problemu()
|
|
|
|
muzi = Resitel.objects.filter(osoba__osloveni=m.Osoba.OSLOVENI_MUZSKE)
|
|
|
|
zeny = Resitel.objects.filter(osoba__osloveni=m.Osoba.OSLOVENI_ZENSKE)
|
|
|
|
return render(request, 'various/stav_databaze.html', {
|
|
|
|
# 'nastaveni': nastaveni,
|
|
|
|
'problemy': problemy,
|
|
|
|
|
|
|
|
'resitele': Resitel.objects.all(),
|
|
|
|
'muzi': muzi,
|
|
|
|
'zeny': zeny,
|
|
|
|
'jmena_muzu': seminar.utils.histogram([r.osoba.jmeno for r in muzi]),
|
|
|
|
'jmena_zen': seminar.utils.histogram([r.osoba.jmeno for r in zeny]),
|
|
|
|
})
|