Browse Source

seminar/templatetags

pull/60/head
Jonas Havelka 5 months ago
parent
commit
85c3969c50
  1. 1
      odevzdavatko/templates/odevzdavatko/tabulka.html
  2. 19
      seminar/templatetags/utils.py
  3. 0
      tvorba/templatetags/__init__.py
  4. 0
      tvorba/templatetags/deadliny.py
  5. 0
      various/templatetags/tex.py

1
odevzdavatko/templates/odevzdavatko/tabulka.html

@ -1,6 +1,5 @@
{% extends "base.html" %}
{% load utils %} {# Možná by mohlo být někde výš v hierarchii templatů... #}
{% load barvy_reseni %}
{% block content %}

19
seminar/templatetags/utils.py

@ -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)

0
seminar/templatetags/__init__.py → tvorba/templatetags/__init__.py

0
seminar/templatetags/deadliny.py → tvorba/templatetags/deadliny.py

0
seminar/templatetags/tex.py → various/templatetags/tex.py

Loading…
Cancel
Save