changeset 84:9e5e52556d5b

Forums: added a last_post_info template tag. Still need to add a go to last post icon for it.
author Brian Neal <bgneal@gmail.com>
date Sat, 29 Aug 2009 22:01:40 +0000
parents 5b4c812b448e
children 531fcc342a03
files gpp/forums/templatetags/__init__.py gpp/forums/templatetags/forum_tags.py gpp/templates/forums/forum_index.html gpp/templates/forums/index.html gpp/templates/forums/last_post_info.html media/css/base.css
diffstat 5 files changed, 25 insertions(+), 18 deletions(-) [+]
line wrap: on
line diff
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/gpp/forums/templatetags/forum_tags.py	Sat Aug 29 22:01:40 2009 +0000
@@ -0,0 +1,11 @@
+"""
+Template tags for the forums application.
+"""
+from django import template
+
+register = template.Library()
+
+
+@register.inclusion_tag('forums/last_post_info.html')
+def last_post_info(post):
+    return {'post': post}
--- a/gpp/templates/forums/forum_index.html	Sat Aug 29 20:54:16 2009 +0000
+++ b/gpp/templates/forums/forum_index.html	Sat Aug 29 22:01:40 2009 +0000
@@ -1,4 +1,5 @@
 {% extends 'base.html' %}
+{% load forum_tags %}
 {% block title %}Forums: {{ forum.name }}{% endblock %}
 {% block content %}
 <h2>Forums: {{ forum.name }}</h2>
@@ -28,12 +29,7 @@
          <td class="forum-index_author">{{ topic.user.username }}</td>
          <td class="forum-index_views">{{ topic.view_count }}</td>
          <td class="forum-index_last_post">
-            {% if topic.last_post %}
-               {{ topic.last_post.update_date|date }}<br />
-               {{ topic.last_post.user.username }}
-            {% else %}
-               <i>No Posts</i>
-            {% endif %}
+            {% last_post_info topic.last_post %}
          </td>
       </tr>
    {% empty %}
--- a/gpp/templates/forums/index.html	Sat Aug 29 20:54:16 2009 +0000
+++ b/gpp/templates/forums/index.html	Sat Aug 29 22:01:40 2009 +0000
@@ -1,4 +1,5 @@
 {% extends 'base.html' %}
+{% load forum_tags %}
 {% block title %}Forums{% endblock %}
 {% block content %}
 <h2>Forums</h2>
@@ -22,14 +23,7 @@
                   <p>{{ forum.description }}</p></td>
                <td class="forum-topics">{{ forum.topic_count }}</td>
                <td class="forum-posts">{{ forum.post_count }}</td>
-               <td class="forum-last_post">
-                  {% if forum.last_post %}
-                     {{ forum.last_post.update_date|date }}<br />
-                     {{ forum.last_post.user.username }}
-                  {% else %}
-                     <i>No Posts</i>
-                  {% endif %}
-               </td>
+               <td class="forum-last_post">{% last_post_info forum.last_post %}</td>
             </tr>
          {% endfor %}
       </tbody>
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/gpp/templates/forums/last_post_info.html	Sat Aug 29 22:01:40 2009 +0000
@@ -0,0 +1,6 @@
+{% if post %}
+{{ post.update_date|date:"M d, Y H:i"}}<br />
+<a href="{% url bio-view_profile username=post.user.username %}" title="View profile for {{ post.user.username }}">{{ post.user.username }}</a>
+{% else %}
+<i>No posts</i>
+{% endif %}
--- a/media/css/base.css	Sat Aug 29 20:54:16 2009 +0000
+++ b/media/css/base.css	Sat Aug 29 22:01:40 2009 +0000
@@ -160,7 +160,7 @@
    background:teal;
 }
 table.forum-index-table .forum-title {
-   width:65%;
+   width:60%;
 }
 table.forum-index-table .forum-topics {
    width:10%;
@@ -171,12 +171,12 @@
    text-align:center;
 }
 table.forum-index-table .forum-last_post {
-   width:15%;
+   width:20%;
    text-align:center;
 }
 
 table.forum-index-table .forum-index_title {
-   width:55%;
+   width:50%;
 }
 table.forum-index-table .forum-index_replies {
    width:10%;
@@ -191,6 +191,6 @@
    text-align:center;
 }
 table.forum-index-table .forum-index_last_post {
-   width:15%;
+   width:20%;
    text-align:center;
 }