diff options
Diffstat (limited to 'proposals/templatetags/icons.py')
-rw-r--r-- | proposals/templatetags/icons.py | 14 |
1 files changed, 14 insertions, 0 deletions
diff --git a/proposals/templatetags/icons.py b/proposals/templatetags/icons.py new file mode 100644 index 0000000..551ad49 --- /dev/null +++ b/proposals/templatetags/icons.py | |||
@@ -0,0 +1,14 @@ | |||
1 | from django import template | ||
2 | from django.utils.html import format_html | ||
3 | from django.contrib.admin.templatetags.admin_static import static | ||
4 | |||
5 | |||
6 | register = template.Library() | ||
7 | |||
8 | |||
9 | @register.filter | ||
10 | def boolean_icon(value): | ||
11 | icon_url = static('admin/img/icon-%s.gif' % | ||
12 | {True: 'yes', False: 'no', None: 'unknown'}[value]) | ||
13 | alt_text = {True: 'yes', False: 'no', None: 'pending' }[value] | ||
14 | return format_html('<img src="{0}" alt="{1}" />', icon_url, alt_text) | ||