# HG changeset patch # User Brian Neal # Date 1303350462 0 # Node ID e06e866af4f18ff4f0cfb57aa3b480855978cecf # Parent c06d836c8b847eb878700fb6cd9fed71b9928cc9 Fixing #207; adding a birthday block. diff -r c06d836c8b84 -r e06e866af4f1 gpp/core/templatetags/core_tags.py --- 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, + } diff -r c06d836c8b84 -r e06e866af4f1 gpp/templates/base.html --- 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 %} SurfGuitar101.com | {% block title %}{% endblock %} @@ -84,6 +85,9 @@ {% cache 3600 poll_block %} {% latest_poll_block %} {% endcache %} + {# cache 3600 birthday_block #} + {% birthday_block %} + {# endcache #} {% include 'core/mp3comp_block.html' %} diff -r c06d836c8b84 -r e06e866af4f1 gpp/templates/core/birthday_block.html --- /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 %} +
Cake
+ +{% else %} +

No birthdays this month.

+{% endif %} +{% endblock %} diff -r c06d836c8b84 -r e06e866af4f1 static/icons/cake.png Binary file static/icons/cake.png has changed