|
|
@ -1,44 +1,32 @@ |
|
|
|
from django import template |
|
|
|
from django.utils.safestring import mark_safe |
|
|
|
from seminar.utils import TypDeadline, deadline |
|
|
|
register = template.Library() |
|
|
|
|
|
|
|
@register.filter(name='deadline') |
|
|
|
def deadline_text(datum): |
|
|
|
if deadline(datum) is None: |
|
|
|
return 'Neznámý deadline' |
|
|
|
typ, cislo, dl = deadline(datum) |
|
|
|
strings = { |
|
|
|
TypDeadline.PredDeadline: f"1. deadline čísla {cislo} ({dl})", |
|
|
|
TypDeadline.SousDeadline: f"Soustřeďkový deadline čísla {cislo} ({dl})", |
|
|
|
TypDeadline.FinalDeadline: f"Finální deadline čísla {cislo} ({dl})", |
|
|
|
} |
|
|
|
return strings[typ] |
|
|
|
import seminar.models as m |
|
|
|
|
|
|
|
@register.filter(name='deadline_kratseji') |
|
|
|
def deadline_kratsi_text(datum): |
|
|
|
if deadline(datum) is None: |
|
|
|
def deadline_kratsi_text(deadline: m.Deadline): |
|
|
|
if deadline is None: |
|
|
|
return 'NONE' |
|
|
|
typ, cislo, dl = deadline(datum) |
|
|
|
strings = { |
|
|
|
TypDeadline.PredDeadline: f"{cislo} ♲", |
|
|
|
TypDeadline.SousDeadline: f"{cislo} Ⓢ", |
|
|
|
TypDeadline.FinalDeadline: f"{cislo} ✓", |
|
|
|
m.Deadline.TYP_PRVNI: f"{deadline.cislo} ♲", |
|
|
|
m.Deadline.TYP_SOUS: f"{deadline.cislo} Ⓢ", |
|
|
|
m.Deadline.TYP_PRVNI_A_SOUS: f"{deadline.cislo} ♲Ⓢ", |
|
|
|
m.Deadline.TYP_CISLA: f"{deadline.cislo} ✓", |
|
|
|
} |
|
|
|
return strings[typ] |
|
|
|
return strings[deadline.typ] |
|
|
|
|
|
|
|
@register.filter(name='deadline_html') |
|
|
|
def deadline_html(datum): |
|
|
|
if deadline(datum) is None: |
|
|
|
def deadline_html(deadline: m.Deadline): |
|
|
|
if deadline is None: |
|
|
|
return 'Neznámý deadline' |
|
|
|
typ, _, _ = deadline(datum) |
|
|
|
text = deadline_kratsi_text(datum) |
|
|
|
text = deadline_kratsi_text(deadline) |
|
|
|
classes = { |
|
|
|
TypDeadline.PredDeadline: 'preddeadline', |
|
|
|
TypDeadline.SousDeadline: 'sous_deadline', |
|
|
|
TypDeadline.FinalDeadline: 'final_deadline', |
|
|
|
m.Deadline.TYP_PRVNI: 'preddeadline', |
|
|
|
m.Deadline.TYP_SOUS: 'sous_deadline', |
|
|
|
m.Deadline.TYP_PRVNI_A_SOUS: 'sous_deadline', |
|
|
|
m.Deadline.TYP_CISLA: 'final_deadline', |
|
|
|
} |
|
|
|
return mark_safe(f'<span class="{classes[typ]}">{text}</span>') |
|
|
|
return mark_safe(f'<span class="{classes[deadline.typ]}">{text}</span>') |
|
|
|
|
|
|
|
@register.filter(name='zkrat_nazev_problemu') |
|
|
|
def zkrat_nazev_problemu(nazev,width): |
|
|
|