changeset 71:fbef4f76492b

Created a bool_icon template tag to graphically display an icon to represent yes/no. Updated profile template to use it.
author Brian Neal <bgneal@gmail.com>
date Wed, 01 Jul 2009 18:34:09 +0000
parents c0d3b09c9b95
children 7f199c85a07c
files gpp/core/templatetags/core_tags.py gpp/templates/bio/view_profile.html media/icons/accept.png media/icons/delete.png
diffstat 4 files changed, 22 insertions(+), 2 deletions(-) [+]
line wrap: on
line diff
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/gpp/core/templatetags/core_tags.py	Wed Jul 01 18:34:09 2009 +0000
@@ -0,0 +1,19 @@
+"""
+Miscellaneous/utility template tags.
+"""
+from django import template
+from django.conf import settings
+
+register = template.Library()
+
+ICON_PARAMS = {
+    True: (settings.MEDIA_URL + 'icons/accept.png', 'Yes'),
+    False: (settings.MEDIA_URL + 'icons/delete.png', 'No'),
+}
+
+@register.simple_tag
+def bool_icon(flag):
+    params = ICON_PARAMS[bool(flag)]
+    return u"""<img src="%s" alt="%s" title="%s" />""" % (
+            params[0], params[1], params[1])
+
--- a/gpp/templates/bio/view_profile.html	Wed Jul 01 17:57:11 2009 +0000
+++ b/gpp/templates/bio/view_profile.html	Wed Jul 01 18:34:09 2009 +0000
@@ -1,6 +1,7 @@
 {% extends 'bio/base.html' %}
 {% load avatar_tags %}
 {% load elsewhere_tags %}
+{% load core_tags %}
 {% block title %}User Profile for {{ subject.username }}{% endblock %}
 {% block content %}
 <div class="user_profile">
@@ -10,8 +11,8 @@
    <tr><th>Full Name</th><td>{{ subject.get_full_name }}</td></tr>
    <tr><th>Date Joined</th><td>{{ subject.date_joined|date:"F d, Y" }}</td></tr>
    <tr><th>Last Login</th><td>{{ subject.last_login|date:"F d, Y @ H:i" }}</td></tr>
-   <tr><th>Active Member</th><td>{{ subject.is_active|yesno:"Yes,No" }}</td></tr>
-   <tr><th>Staff Member</th><td>{{ subject.is_staff|yesno:"Yes,No" }}</td></tr>
+   <tr><th>Active Member</th><td>{% bool_icon subject.is_active %}</td></tr>
+   <tr><th>Staff Member</th><td>{% bool_icon subject.is_staff %}</td></tr>
    {% if profile.location %}
    <tr><th>Location</th><td>{{ profile.location }}</td></tr>
    {% endif %}
Binary file media/icons/accept.png has changed
Binary file media/icons/delete.png has changed