Mercurial > public > sg101
changeset 421:e06e866af4f1
Fixing #207; adding a birthday block.
author | Brian Neal <bgneal@gmail.com> |
---|---|
date | Thu, 21 Apr 2011 01:47:42 +0000 |
parents | c06d836c8b84 |
children | 6309814cd6f7 |
files | gpp/core/templatetags/core_tags.py gpp/templates/base.html gpp/templates/core/birthday_block.html static/icons/cake.png |
diffstat | 4 files changed, 38 insertions(+), 0 deletions(-) [+] |
line wrap: on
line diff
--- a/gpp/core/templatetags/core_tags.py Wed Apr 20 23:42:10 2011 +0000 +++ b/gpp/core/templatetags/core_tags.py Thu Apr 21 01:47:42 2011 +0000 @@ -10,6 +10,7 @@ import repoze.timeago from core.models import UserLastVisit, AnonLastVisit +from bio.models import UserProfile register = template.Library() @@ -78,3 +79,20 @@ """ return repoze.timeago.get_elapsed(timestamp) elapsed.is_safe = True + + +@register.inclusion_tag('core/birthday_block.html') +def birthday_block(): + """ + A template tag to display all the users who have birthdays this month. + """ + today = datetime.date.today() + profiles = list(UserProfile.objects.filter(birthday__month=today.month).select_related( + 'user')) + profiles.sort(key=lambda p: p.birthday.day) + + return { + 'STATIC_URL': settings.STATIC_URL, + 'profiles': profiles, + 'today': today, + }
--- a/gpp/templates/base.html Wed Apr 20 23:42:10 2011 +0000 +++ b/gpp/templates/base.html Thu Apr 21 01:47:42 2011 +0000 @@ -9,6 +9,7 @@ {% load messages_tags %} {% load script_tags %} {% load poll_tags %} +{% load core_tags %} {% load cache %} <head><title>SurfGuitar101.com | {% block title %}{% endblock %}</title> <meta http-equiv="Content-Type" content="text/html" /> @@ -84,6 +85,9 @@ {% cache 3600 poll_block %} {% latest_poll_block %} {% endcache %} + {# cache 3600 birthday_block #} + {% birthday_block %} + {# endcache #} {% include 'core/mp3comp_block.html' %} </div>
--- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/gpp/templates/core/birthday_block.html Thu Apr 21 01:47:42 2011 +0000 @@ -0,0 +1,16 @@ +{% extends 'side_block.html' %} +{% load url from future %} +{% load humanize %} +{% block block_title %}{{ today|date:"F" }} Birthdays{% endblock %} +{% block block_content %} +{% if profiles %} + <div class="centeredImage"><img src="{{ STATIC_URL }}icons/cake.png" alt="Cake" /></div> + <ul> + {% for profile in profiles %} + <li>{{ profile.birthday.day|ordinal }} – <a href="{% url 'bio-view_profile' username=profile.user.username %}">{{ profile.user.username }}</a></li> + {% endfor %} + </ul> +{% else %} + <p>No birthdays this month.</p> +{% endif %} +{% endblock %}