|
|
@ -2,6 +2,7 @@ from django import forms |
|
|
|
from dal import autocomplete |
|
|
|
from django.forms import formset_factory |
|
|
|
from django.forms.models import inlineformset_factory |
|
|
|
from django.utils import timezone |
|
|
|
|
|
|
|
from seminar.models import Resitel |
|
|
|
import seminar.models as m |
|
|
@ -141,7 +142,6 @@ class OdevzdavatkoTabulkaFiltrForm(forms.Form): |
|
|
|
from django.db.utils import OperationalError |
|
|
|
try: |
|
|
|
aktualni_rocnik = m.Nastaveni.get_solo().aktualni_rocnik |
|
|
|
aktualni_cislo = m.Nastaveni.get_solo().aktualni_cislo |
|
|
|
except OperationalError: |
|
|
|
# django.db.utils.OperationalError: no such table: seminar_nastaveni |
|
|
|
# Nemáme databázi, takže to selhalo. Pro jistotu vrátíme aspoň dvě možnosti, ať to nepadá dál |
|
|
@ -152,31 +152,18 @@ class OdevzdavatkoTabulkaFiltrForm(forms.Form): |
|
|
|
# FIXME: Tohle je hnusný monkey patch, mělo by to být nějak zahrnuto výš. |
|
|
|
if rocnik is not None: |
|
|
|
aktualni_rocnik = rocnik |
|
|
|
aktualni_cislo = m.Cislo.objects.filter(rocnik=rocnik).order_by('poradi').last() |
|
|
|
|
|
|
|
result = [] |
|
|
|
|
|
|
|
for cislo in m.Cislo.objects.filter( |
|
|
|
rocnik=aktualni_rocnik, |
|
|
|
poradi__lte=aktualni_cislo.poradi, |
|
|
|
).reverse(): # Standardně se řadí od nejnovějšího čísla |
|
|
|
# Předem je mi líto kohokoliv, kdo tyhle řádky bude číst... |
|
|
|
if cislo.datum_vydani is not None and cislo.datum_vydani <= datetime.date.today(): |
|
|
|
result.append(( |
|
|
|
strftime(DATE_FORMAT, cislo.datum_vydani.timetuple()), |
|
|
|
f"Vydání {cislo.poradi}. čísla")) |
|
|
|
if cislo.datum_preddeadline is not None and cislo.datum_preddeadline <= datetime.date.today(): |
|
|
|
result.append(( |
|
|
|
strftime(DATE_FORMAT, cislo.datum_preddeadline.timetuple()), |
|
|
|
f"Předdeadline {cislo.poradi}. čísla")) |
|
|
|
if cislo.datum_deadline_soustredeni is not None and cislo.datum_deadline_soustredeni <= datetime.date.today(): |
|
|
|
result.append(( |
|
|
|
strftime(DATE_FORMAT, cislo.datum_deadline_soustredeni.timetuple()), |
|
|
|
f"Sous. deadline {cislo.poradi}. čísla")) |
|
|
|
if cislo.datum_deadline is not None and cislo.datum_deadline <= datetime.date.today(): |
|
|
|
for deadline in m.Deadline.objects.filter( |
|
|
|
deadline__lte=timezone.now(), |
|
|
|
cislo__rocnik=aktualni_rocnik |
|
|
|
).order_by("deadline").reverse(): |
|
|
|
|
|
|
|
result.append(( |
|
|
|
strftime(DATE_FORMAT, cislo.datum_deadline.timetuple()), |
|
|
|
f"Finální deadline {cislo.poradi}. čísla")) |
|
|
|
strftime(DATE_FORMAT, deadline.deadline.timetuple()), |
|
|
|
str(deadline))) |
|
|
|
|
|
|
|
result.append(( |
|
|
|
strftime(DATE_FORMAT, datetime.date.today().timetuple()), f"Dnes")) |
|
|
|
|
|
|
|