TitulniStranaView: Preddeadline přidán do contextu
This commit is contained in:
parent
d3af7d3134
commit
ce4ca5b05d
1 changed files with 23 additions and 28 deletions
|
@ -24,7 +24,7 @@ from seminar import utils, treelib
|
||||||
from seminar.forms import PrihlaskaForm, LoginForm, ProfileEditForm
|
from seminar.forms import PrihlaskaForm, LoginForm, ProfileEditForm
|
||||||
import seminar.forms as f
|
import seminar.forms as f
|
||||||
|
|
||||||
from datetime import timedelta, date, datetime
|
from datetime import timedelta, date, datetime, MAXYEAR
|
||||||
from django.utils import timezone
|
from django.utils import timezone
|
||||||
from itertools import groupby
|
from itertools import groupby
|
||||||
from collections import OrderedDict
|
from collections import OrderedDict
|
||||||
|
@ -259,35 +259,30 @@ class TitulniStranaView(generic.ListView):
|
||||||
def get_context_data(self, **kwargs):
|
def get_context_data(self, **kwargs):
|
||||||
context = super(TitulniStranaView, self).get_context_data(**kwargs)
|
context = super(TitulniStranaView, self).get_context_data(**kwargs)
|
||||||
nastaveni = get_object_or_404(Nastaveni)
|
nastaveni = get_object_or_404(Nastaveni)
|
||||||
|
|
||||||
|
deadline_soustredeni = (nastaveni.aktualni_cislo.datum_deadline_soustredeni, "soustredeni")
|
||||||
|
preddeadline = (nastaveni.aktualni_cislo.datum_preddeadline, "preddeadline")
|
||||||
|
deadline = (nastaveni.aktualni_cislo.datum_deadline, "deadline")
|
||||||
|
|
||||||
# zjisteni spravneho terminu
|
try:
|
||||||
if nastaveni.aktualni_cislo.datum_deadline_soustredeni:
|
nejblizsi_deadline = sorted(filter(lambda dl: dl[0] is not None and dl[0] >= date.today(), [deadline_soustredeni, preddeadline, deadline]))[0]
|
||||||
cas_deadline_soustredeni = nastaveni.aktualni_cislo.\
|
except IndexError:
|
||||||
datum_deadline_soustredeni
|
nejblizsi_deadline = (None, None) # neni zadna aktualni deadline
|
||||||
if (datetime.now().date() <= cas_deadline_soustredeni):
|
|
||||||
cas_deadline = cas_deadline_soustredeni
|
|
||||||
deadline_soustredeni = True
|
|
||||||
else:
|
|
||||||
cas_deadline = nastaveni.aktualni_cislo.datum_deadline
|
|
||||||
deadline_soustredeni = False
|
|
||||||
else:
|
|
||||||
cas_deadline = nastaveni.aktualni_cislo.datum_deadline
|
|
||||||
deadline_soustredeni = False
|
|
||||||
|
|
||||||
# Pokud neni zverejnene cislo nezverejnuj odpocet
|
if nejblizsi_deadline[0] is not None:
|
||||||
if nastaveni.aktualni_cislo.verejne():
|
context['nejblizsi_deadline'] = datetime.combine(nejblizsi_deadline[0], datetime.max.time())
|
||||||
# pokus se zjistit termin odeslani a pokud neni zadany,
|
|
||||||
# nezverejnuj odpocet
|
|
||||||
context['deadline_soustredeni'] = deadline_soustredeni
|
|
||||||
try:
|
|
||||||
context['dead'] = datetime.combine(cas_deadline,
|
|
||||||
datetime.max.time())
|
|
||||||
context['ted'] = datetime.now()
|
|
||||||
except:
|
|
||||||
context['dead'] = None
|
|
||||||
else:
|
else:
|
||||||
context['dead'] = None
|
context['nejblizsi_deadline'] = None
|
||||||
context['deadline_soustredeni'] = deadline_soustredeni
|
|
||||||
|
context['typ_deadline'] = nejblizsi_deadline[1]
|
||||||
|
context['ted'] = datetime.now()
|
||||||
|
|
||||||
|
if (nejblizsi_deadline[1] == 'soustredeni'):
|
||||||
|
context['dead'] = datetime.combine(deadline_soustredeni[0], datetime.max.time())
|
||||||
|
context['deadline_soustredeni'] = True
|
||||||
|
else:
|
||||||
|
context['dead'] = context['nejblizsi_deadline']
|
||||||
|
context['deadline_soustredeni'] = False
|
||||||
|
|
||||||
# Aktuální témata
|
# Aktuální témata
|
||||||
nazvy_a_odkazy_na_aktualni_temata = []
|
nazvy_a_odkazy_na_aktualni_temata = []
|
||||||
|
@ -1361,4 +1356,4 @@ class JakResitView(generic.ListView):
|
||||||
template_name = 'seminar/jak-resit.html'
|
template_name = 'seminar/jak-resit.html'
|
||||||
|
|
||||||
def get_queryset(self):
|
def get_queryset(self):
|
||||||
return None
|
return None
|
||||||
|
|
Loading…
Reference in a new issue