Pavel "LEdoian" Turinsky
4 years ago
1 changed files with 24 additions and 0 deletions
@ -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 new issue