Templatetagy na hezké vykreslování a dohledávání deadlinů
Nikdo neví, k čemu jsou dobré, ale už jsou napsané...
This commit is contained in:
parent
3b24c6e19e
commit
2a292f3a82
1 changed files with 24 additions and 0 deletions
24
seminar/templatetags/deadliny.py
Normal file
24
seminar/templatetags/deadliny.py
Normal file
|
@ -0,0 +1,24 @@
|
||||||
|
from django import template
|
||||||
|
from seminar.utils import TypDeadline, deadline
|
||||||
|
register = template.Library()
|
||||||
|
|
||||||
|
@register.filter(name='deadline')
|
||||||
|
def deadline_text(datum):
|
||||||
|
typ, cislo, deadline = deadline(datum)
|
||||||
|
strings = {
|
||||||
|
TypDeadline.PredDeadline: f"1. deadline čísla {cislo} ({datum})",
|
||||||
|
TypDeadline.SousDeadline: f"Soustřeďkový deadline čísla {cislo} ({datum})",
|
||||||
|
TypDeadline.FinalDeadline: f"Finální deadline čísla {cislo} ({datum})",
|
||||||
|
}
|
||||||
|
return strings[typ]
|
||||||
|
|
||||||
|
@register.filter(name='deadline_html')
|
||||||
|
def deadline_html(datum):
|
||||||
|
typ, _, _ = deadline(datum)
|
||||||
|
text = deadline_text(datum)
|
||||||
|
classes = {
|
||||||
|
TypDeadline.PredDeadline: 'preddeadline',
|
||||||
|
TypDeadline.SousDeadline: 'sous_deadline',
|
||||||
|
TypDeadline.FinalDeadline: 'final_deadline',
|
||||||
|
}
|
||||||
|
return f'<span class="{classes[typ]}">{text}</span>'
|
Loading…
Reference in a new issue