seminar/templatetags
This commit is contained in:
parent
18364eb531
commit
85c3969c50
5 changed files with 0 additions and 20 deletions
|
@ -1,6 +1,5 @@
|
||||||
{% extends "base.html" %}
|
{% extends "base.html" %}
|
||||||
|
|
||||||
{% load utils %} {# Možná by mohlo být někde výš v hierarchii templatů... #}
|
|
||||||
{% load barvy_reseni %}
|
{% load barvy_reseni %}
|
||||||
|
|
||||||
{% block content %}
|
{% block content %}
|
||||||
|
|
|
@ -1,19 +0,0 @@
|
||||||
from django import template
|
|
||||||
from django.utils.safestring import mark_safe
|
|
||||||
from datetime import datetime, timedelta
|
|
||||||
from mamweb.settings import TIME_ZONE
|
|
||||||
import logging
|
|
||||||
register = template.Library()
|
|
||||||
|
|
||||||
logger = logging.getLogger(__name__)
|
|
||||||
|
|
||||||
@register.filter(name='kratke_datum', expects_localtime=True)
|
|
||||||
def kratke_datum(dt):
|
|
||||||
# None dává None, ne-datum dává False, aby se daly použít filtry typu "default".
|
|
||||||
if dt is None:
|
|
||||||
return None
|
|
||||||
if not isinstance(dt, datetime):
|
|
||||||
logger.warning(f"Špatné volání filtru {__name__}: {dt}")
|
|
||||||
return False
|
|
||||||
out = f'<time datetime="{dt.isoformat()}" title="{dt.strftime("%d. %m. %Y %H:%M")}">{dt.day}.{dt.month}.<span style="text-decoration:overline">{dt.year%100}</time>'
|
|
||||||
return mark_safe(out)
|
|
Loading…
Reference in a new issue