From 2a292f3a828a62241c377d6d0ab1f77e050c0d5f Mon Sep 17 00:00:00 2001 From: "Pavel \"LEdoian\" Turinsky" Date: Tue, 30 Mar 2021 22:26:37 +0200 Subject: [PATCH] =?UTF-8?q?Templatetagy=20na=20hezk=C3=A9=20vykreslov?= =?UTF-8?q?=C3=A1n=C3=AD=20a=20dohled=C3=A1v=C3=A1n=C3=AD=20deadlin=C5=AF?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Nikdo neví, k čemu jsou dobré, ale už jsou napsané... --- seminar/templatetags/deadliny.py | 24 ++++++++++++++++++++++++ 1 file changed, 24 insertions(+) create mode 100644 seminar/templatetags/deadliny.py diff --git a/seminar/templatetags/deadliny.py b/seminar/templatetags/deadliny.py new file mode 100644 index 00000000..29ea5c79 --- /dev/null +++ b/seminar/templatetags/deadliny.py @@ -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'{text}'