Browse Source

TitulniStranaView: Preddeadline přidán do contextu

export_seznamu_prednasek
Pavel Turinský 4 years ago
parent
commit
ce4ca5b05d
  1. 49
      seminar/views/views_all.py

49
seminar/views/views_all.py

@ -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
@ -260,34 +260,29 @@ class TitulniStranaView(generic.ListView):
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)
# zjisteni spravneho terminu deadline_soustredeni = (nastaveni.aktualni_cislo.datum_deadline_soustredeni, "soustredeni")
if nastaveni.aktualni_cislo.datum_deadline_soustredeni: preddeadline = (nastaveni.aktualni_cislo.datum_preddeadline, "preddeadline")
cas_deadline_soustredeni = nastaveni.aktualni_cislo.\ deadline = (nastaveni.aktualni_cislo.datum_deadline, "deadline")
datum_deadline_soustredeni
if (datetime.now().date() <= cas_deadline_soustredeni): try:
cas_deadline = cas_deadline_soustredeni nejblizsi_deadline = sorted(filter(lambda dl: dl[0] is not None and dl[0] >= date.today(), [deadline_soustredeni, preddeadline, deadline]))[0]
deadline_soustredeni = True except IndexError:
else: nejblizsi_deadline = (None, None) # neni zadna aktualni deadline
cas_deadline = nastaveni.aktualni_cislo.datum_deadline
deadline_soustredeni = False if nejblizsi_deadline[0] is not None:
context['nejblizsi_deadline'] = datetime.combine(nejblizsi_deadline[0], datetime.max.time())
else: else:
cas_deadline = nastaveni.aktualni_cislo.datum_deadline context['nejblizsi_deadline'] = None
deadline_soustredeni = False
context['typ_deadline'] = nejblizsi_deadline[1]
# Pokud neni zverejnene cislo nezverejnuj odpocet context['ted'] = datetime.now()
if nastaveni.aktualni_cislo.verejne():
# pokus se zjistit termin odeslani a pokud neni zadany, if (nejblizsi_deadline[1] == 'soustredeni'):
# nezverejnuj odpocet context['dead'] = datetime.combine(deadline_soustredeni[0], datetime.max.time())
context['deadline_soustredeni'] = deadline_soustredeni context['deadline_soustredeni'] = True
try:
context['dead'] = datetime.combine(cas_deadline,
datetime.max.time())
context['ted'] = datetime.now()
except:
context['dead'] = None
else: else:
context['dead'] = None context['dead'] = context['nejblizsi_deadline']
context['deadline_soustredeni'] = deadline_soustredeni context['deadline_soustredeni'] = False
# Aktuální témata # Aktuální témata
nazvy_a_odkazy_na_aktualni_temata = [] nazvy_a_odkazy_na_aktualni_temata = []

Loading…
Cancel
Save