# HG changeset patch # User Brian Neal # Date 1456282308 21600 # Node ID 7cfa4bbe0a09c4e78f77b917a953b842801040cc # Parent 61abc6f6530cbaa5101584a01347dce7691b4dc7 More V3 work in progress. diff -r 61abc6f6530c -r 7cfa4bbe0a09 core/templatetags/core_tags.py --- a/core/templatetags/core_tags.py Sun Feb 07 20:44:03 2016 -0600 +++ b/core/templatetags/core_tags.py Tue Feb 23 20:51:48 2016 -0600 @@ -158,14 +158,14 @@ self.profiles = profiles if profiles else [] -@register.inclusion_tag('core/birthday_block.html') -def birthday_block(): +@register.simple_tag(takes_context=True) +def birthday_block(context): """ 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 = list(UserProfile.objects.filter(birthday__month=today.month)\ + .select_related('user')) days = collections.defaultdict(list) for profile in profiles: @@ -174,10 +174,13 @@ birthdays = [Birthday(day, profiles) for day, profiles in days.iteritems()] birthdays.sort(key=lambda b: b.day) - return { - 'birthdays': birthdays, - 'today': today, - } + context['birthdays'] = birthdays + context['today'] = today + + template_name = ('core/v3/birthday_block.html' + if 'V3_DESIGN' in context else 'core/birthday_block.html') + t = template.loader.get_template(template_name) + return t.render(context) class EncodeParamsNode(template.Node): diff -r 61abc6f6530c -r 7cfa4bbe0a09 donations/templatetags/donations_tags.py --- a/donations/templatetags/donations_tags.py Sun Feb 07 20:44:03 2016 -0600 +++ b/donations/templatetags/donations_tags.py Tue Feb 23 20:51:48 2016 -0600 @@ -13,7 +13,6 @@ @register.simple_tag(takes_context=True) def monthly_goal(context): context['pct'] = Donation.objects.monthly_goal_pct() - context['pct'] = 10 template_name = ('donations/v3/monthly_goal_tag.html' if 'V3_DESIGN' in context else 'donations/monthly_goal_tag.html') diff -r 61abc6f6530c -r 7cfa4bbe0a09 messages/templatetags/messages_tags.py --- a/messages/templatetags/messages_tags.py Sun Feb 07 20:44:03 2016 -0600 +++ b/messages/templatetags/messages_tags.py Tue Feb 23 20:51:48 2016 -0600 @@ -11,10 +11,18 @@ register = template.Library() -@register.inclusion_tag('messages/unread_messages_tag.html') -def unread_messages(user): - unread_count = Message.objects.unread_count(user) - return {'unread_count': unread_count} +@register.simple_tag(takes_context=True) +def unread_messages(context): + user = context['user'] + if user.is_authenticated(): + unread_count = Message.objects.unread_count(user) + else: + unread_count = None + context['unread_count'] = unread_count + template_name = ('messages/v3/unread_messages_tag.html' + if 'V3_DESIGN' in context else 'messages/unread_messages_tag.html') + t = template.loader.get_template(template_name) + return t.render(context) @register.simple_tag diff -r 61abc6f6530c -r 7cfa4bbe0a09 sg101/templates/core/v3/birthday_block.html --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/sg101/templates/core/v3/birthday_block.html Tue Feb 23 20:51:48 2016 -0600 @@ -0,0 +1,21 @@ +{% load bio_tags %} +{% load humanize %} +
+
+
{{ today|date:"F" }} Birthdays
+
+ +
diff -r 61abc6f6530c -r 7cfa4bbe0a09 sg101/templates/messages/v3/unread_messages_tag.html --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/sg101/templates/messages/v3/unread_messages_tag.html Tue Feb 23 20:51:48 2016 -0600 @@ -0,0 +1,3 @@ +{% if unread_count > 0 %} +{{ unread_count }} +{% endif %} diff -r 61abc6f6530c -r 7cfa4bbe0a09 sg101/templates/navbar.html --- a/sg101/templates/navbar.html Sun Feb 07 20:44:03 2016 -0600 +++ b/sg101/templates/navbar.html Tue Feb 23 20:51:48 2016 -0600 @@ -3,7 +3,7 @@ {% if user.is_authenticated %}
  • Welcome, {{ user.username }}
  • Forums
  • -
  • {% unread_messages user %}
  • +
  • {% unread_messages %}
  • Search
  • Logout
  • {% else %} diff -r 61abc6f6530c -r 7cfa4bbe0a09 sg101/templates/v3/base.html --- a/sg101/templates/v3/base.html Sun Feb 07 20:44:03 2016 -0600 +++ b/sg101/templates/v3/base.html Tue Feb 23 20:51:48 2016 -0600 @@ -3,8 +3,10 @@ {% load cache %} {% load static from staticfiles %} {% load contest_tags %} +{% load core_tags %} {% load donations_tags %} {% load irc_tags %} +{% load messages_tags %} {% load poll_tags %} {% load potd_tags %} @@ -18,9 +20,6 @@ - - - {% block custom_head %}{% endblock %} {% block custom_css %}{% endblock %} @@ -32,7 +31,8 @@
  • SurfGuitar101
  • {% if user.is_authenticated %}
  • {{ user.username }}'s Profile
  • -
  • Private Messages 25
  • +
  • Private Messages + {% unread_messages %}
  • Logout
  • {% else %}
  • Login
  • @@ -72,38 +72,44 @@ @@ -128,21 +134,47 @@ {# cache 600 donations_block #} {% monthly_goal %} {# endcache #} + {# cache 3600 birthday_block #} + {% birthday_block %} + {# endcache #}
    {% block content %}{% endblock %}
    - - - - + - - + + + +