changeset 1047:7cfa4bbe0a09

More V3 work in progress.
author Brian Neal <bgneal@gmail.com>
date Tue, 23 Feb 2016 20:51:48 -0600
parents 61abc6f6530c
children e9f577686867
files core/templatetags/core_tags.py donations/templatetags/donations_tags.py messages/templatetags/messages_tags.py sg101/templates/core/v3/birthday_block.html sg101/templates/messages/v3/unread_messages_tag.html sg101/templates/navbar.html sg101/templates/v3/base.html
diffstat 7 files changed, 113 insertions(+), 47 deletions(-) [+]
line wrap: on
line diff
--- 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):
--- 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')
--- 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
--- /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 %}
+<div class="callout">
+   <div class="text-center">
+      <h5>{{ today|date:"F" }} Birthdays</h5>
+   </div>
+   <ul class="no-bullet">
+      {% for bday in birthdays %}
+      <li>
+      {% if bday.day == today.day %}<strong>{% endif %}
+      {{ bday.day|ordinal }} &ndash;
+      {% for profile in bday.profiles %}
+      <a href="{% url 'bio-view_profile' profile.user.username %}" title="View profile for {{ profile.user.username }}">{{ profile.user.username }}</a>{% if not forloop.last %}, {% endif %}
+      {% endfor %}
+      {% if bday.day == today.day %}</strong>{% endif %}
+      </li>
+      {% empty %}
+         <li>No birthdays this month</li>
+      {% endfor %}
+   </ul>
+</div>
--- /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 %}
+<span class="alert badge size-14">{{ unread_count }}</span>
+{% endif %}
--- 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 %}
    <li>Welcome, <a href="{% url 'bio-me' %}">{{ user.username }}</a></li>
    <li><a href="{% url 'forums-index' %}">Forums</a></li>
-   <li>{% unread_messages user %}</li>
+   <li>{% unread_messages %}</li>
    <li><a href="{% url 'haystack_search' %}">Search</a></li>
    <li><a href="{% url 'accounts-logout' %}">Logout</a></li>
    {% else %}
--- 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 %}
 <head prefix="og: http://ogp.me/ns# fb: http://ogp.me/ns/fb#">
@@ -18,9 +20,6 @@
    <link rel="stylesheet" href="{% static "css/v3/main.min.css" %}">
    <link rel="stylesheet" href="{% static "css/v3/foundation-icons.css" %}" />
    <link rel="shortcut icon" href="{% static "favicon.ico" %}">
-   <!-- link rel="stylesheet" href="http://dhbhdrzi4tiry.cloudfront.net/cdn/sites/foundation.min.css"-->
-   <!-- link href='http://cdnjs.cloudflare.com/ajax/libs/foundicons/3.0.0/foundation-icons.css' rel='stylesheet' type='text/css' -->
-   <!-- link rel="stylesheet" href="https://cdn.jsdelivr.net/foundation/6.1.2/foundation.min.css"-->
    {% block custom_head %}{% endblock %}
    {% block custom_css %}{% endblock %}
 </head>
@@ -32,7 +31,8 @@
             <li><a href="/">SurfGuitar101</a></li>
             {% if user.is_authenticated %}
                <li><a href="{% url 'bio-me' %}">{{ user.username }}'s Profile</a></li>
-               <li><a href="{% url 'messages-inbox' %}">Private Messages <span class="alert badge">25</span></a></li>
+               <li><a href="{% url 'messages-inbox' %}">Private Messages
+                  {% unread_messages %}</a></li>
                <li><a href="{% url 'accounts-logout' %}">Logout</a></li>
             {% else %}
                <li><a href="{% url 'accounts-login' %}">Login</a></li>
@@ -72,38 +72,44 @@
 <ul class="menu vertical medium-horizontal expanded XXXmedium-text-center" data-responsive-menu="drilldown medium-dropdown">
 <li class=""><a href="#">News</a>
    <ul class="menu vertical" data-submenu>
-      <li><a href="#">News</a></li>
-      <li><a href="#">Submit News</a></li>
+      <li><a href="{% url 'news-index_page' %}">News</a></li>
+      <li><a href="{% url 'news-submit' %}">Submit News</a></li>
    </ul>
 </li>
 <li class=""><a href="#">Forums</a>
    <ul class="menu vertical" data-submenu>
-      <li><a href="#">Latest Posts</a></li>
-      <li><a href="#">All Forums</a></li>
+      <li><a href="{% url 'forums-unread_topics' %}">Unread Topics</a></li>
+      <li><a href="{% url 'forums-active_topics' 30 %}">Active Topics</a></li>
+      <li><a href="{% url 'forums-index' %}">All Forums</a></li>
+      <li><a href="{% url 'forums-my_posts' %}">My Posts</a></li>
+      <li><a href="{% url 'forums-manage_favorites' %}">My Favorites</a></li>
+      <li><a href="{% url 'forums-manage_subscriptions' %}">My Subscriptions</a></li>
+      <li><a href="{% url 'forums-unanswered_topics' %}">Unanswered Topics</a></li>
    </ul>
 </li>
 <li class=""><a href="#">Surf Music</a>
    <ul class="menu vertical" data-submenu>
-      <li><a href="#">Calendar</a></li>
-      <li><a href="#">Contests</a></li>
-      <li><a href="#">Downloads</a></li>
-      <li><a href="#">Podcasts</a></li>
-      <li><a href="#">Polls</a></li>
-      <li><a href="#">Photo of the Day</a></li>
-      <li><a href="#">Links</a></li>
-      <li><a href="#">Surf Band Map</a></li>
+      <li><a href="{% url 'gcalendar-index' %}">Calendar</a></li>
+      <li><a href="{% url 'contests-index' %}">Contests</a></li>
+      <li><a href="{% url 'downloads-index' %}">Downloads</a></li>
+      <li><a href="{% url 'podcast-main' %}">Podcast</a></li>
+      <li><a href="{% url 'polls-main' %}">Polls</a></li>
+      <li><a href="{% url 'potd-view' %}">Photo of the Day</a></li>
+      <li><a href="{% url 'weblinks-main' %}">Links</a></li>
+      <li><a href="{% url 'bandmap-map' %}">Surf Band Map</a></li>
+      <li><a href="{% url 'ygroup-thread_index' %}">Yahoo Group</a></li>
    </ul>
 </li>
 <li class=""><a href="#">Site</a>
    <ul class="menu vertical" data-submenu>
-      <li><a href="#">Contact</a></li>
-      <li><a href="#">Chat / IRC</a></li>
-      <li><a href="#">Donations</a></li>
-      <li><a href="#">Member List</a></li>
-      <li><a href="#">Member Map</a></li>
-      <li><a href="#">Search</a></li>
-      <li><a href="#">Store</a></li>
-      <li><a href="#">Wiki</a></li>
+      <li><a href="{% url 'contact-form' %}">Contact</a></li>
+      <li><a href="{% url 'irc-main' %}">Chat/IRC</a></li>
+      <li><a href="{% url 'donations-index' %}">Donations</a></li>
+      <li><a href="{% url 'bio-member_list' type='user' %}">Member List</a></li>
+      <li><a href="{% url 'bio-member_search' %}">Member Search</a></li>
+      <li><a href="{% url 'membermap-index' %}">Member Map</a></li>
+      <li><a href="/store/">Store</a></li>
+      <li><a href="http://wiki.surfguitar101.com">Wiki</a></li>
    </ul>
 </li>
 </ul>
@@ -128,21 +134,47 @@
       {# cache 600 donations_block #}
          {% monthly_goal %}
       {# endcache #}
+      {# cache 3600 birthday_block #}
+         {% birthday_block %}
+      {# endcache #}
    </div>
    <div class="medium-9 columns">
    {% block content %}{% endblock %}
    </div>
 </div>
-   <script src="https://ajax.googleapis.com/ajax/libs/jquery/2.1.4/jquery.min.js"></script>
-   <script src="{% static "js/v3/what-input.min.js" %}"></script>
-   <script src="{% static "js/v3/foundation.min.js" %}"></script>
 
-   <!--
-   <script src="http://dhbhdrzi4tiry.cloudfront.net/cdn/sites/foundation.js"></script>
-   <script src="https://cdn.jsdelivr.net/foundation/6.1.2/foundation.min.js"></script>
-   -->
+<footer>
+<div class="row expanded callout secondary align-middle">
+   <div class="medium-4 columns">
+      <a href="https://www.twitter.com/SurfGuitar101">
+      <i class="fi-social-twitter size-72"></i>
+      Follow SurfGuitar101 on Twitter!</a>
+   </div>
+   <div class="medium-4 columns">
+      <ul>
+         <li>Contact Us</li>
+         <li>About Us</li>
+         <li>Terms of Service</li>
+         <li>Privacy Policy</li>
+         <li>Colophon</li>
+      </ul>
+   </div>
+   <div class="medium-4 columns">
+      <p>
+         SurfGuitar101.com © 2004 - 2016 by Brian Neal. All comments and user 
+         contributed articles are property of the posters.
+      </p>
+      <p>
+         Thanks to all the surf bands, past and present. And thanks to all the
+         fans who care about and keep surf music alive.
+      </p>
+   </div>
+</div>
+</footer>
 
-   <script src="{% static "js/v3/sg101.js" %}"></script>
-
+<script src="https://ajax.googleapis.com/ajax/libs/jquery/2.1.4/jquery.min.js"></script>
+<script src="{% static "js/v3/what-input.min.js" %}"></script>
+<script src="{% static "js/v3/foundation.min.js" %}"></script>
+<script src="{% static "js/v3/sg101.js" %}"></script>
 </body>
 </html>