diff options
author | Luke Shumaker <lukeshu@parabola.nu> | 2019-03-23 20:05:34 -0400 |
---|---|---|
committer | Luke Shumaker <lukeshu@parabola.nu> | 2019-03-23 20:05:34 -0400 |
commit | 87bd4a32b2eb983a34bf28eaee6e2c6ce5a405ee (patch) | |
tree | f8686805323e4c71c582480aaa64203415240a03 /mirrors/templatetags/jinja2.py | |
parent | 7f68a8f0f79ac1548aaece3ebd65a296714163a6 (diff) | |
parent | a526410f2a5be83c0b853bb4e7624c77997ccd61 (diff) |
Merge branch 'archweb-generic' into lukeshu/master
Diffstat (limited to 'mirrors/templatetags/jinja2.py')
-rw-r--r-- | mirrors/templatetags/jinja2.py | 53 |
1 files changed, 0 insertions, 53 deletions
diff --git a/mirrors/templatetags/jinja2.py b/mirrors/templatetags/jinja2.py deleted file mode 100644 index 04e50238..00000000 --- a/mirrors/templatetags/jinja2.py +++ /dev/null @@ -1,53 +0,0 @@ -from datetime import timedelta -from django_jinja import library -from markupsafe import Markup - - -@library.global_function -def country_flag(country): - if not country: - return '' - html = '<span class="fam-flag fam-flag-%s" title="%s"></span> ' % ( - unicode(country.code).lower(), unicode(country.name)) - return Markup(html) - - -@library.filter -def duration(value): - if not value and type(value) != timedelta: - return u'' - # does not take microseconds into account - total_secs = value.seconds + value.days * 24 * 3600 - mins = total_secs // 60 - hrs, mins = divmod(mins, 60) - return '%d:%02d' % (hrs, mins) - - -@library.filter -def hours(value): - if not value and type(value) != timedelta: - return u'' - # does not take microseconds into account - total_secs = value.seconds + value.days * 24 * 3600 - mins = total_secs // 60 - hrs, mins = divmod(mins, 60) - if hrs == 1: - return '%d hour' % hrs - return '%d hours' % hrs - - -@library.filter -def floatvalue(value, arg=2): - if value is None: - return u'' - return '%.*f' % (arg, value) - - -@library.filter -def percentage(value, arg=1): - if not value and type(value) != float: - return u'' - new_val = value * 100.0 - return '%.*f%%' % (arg, new_val) - -# vim: set ts=4 sw=4 et: |