Add a new templatetag to render modified on and by line in documents.
authorMadhusudan.C.S <madhusudancs@gmail.com>
Thu, 20 Jan 2011 17:42:46 +0530
changeset 498 9f04b7bcc333
parent 497 6386458d749b
child 499 2dfecac4b545
Add a new templatetag to render modified on and by line in documents. Add the necessary div tags, html templates, templatetag function and the CSS to give necessary layout and styling.
pytask/static/css/base.css
pytask/templates/task/view_textbook.html
pytask/templates/templatetags/_as_modification_display.html
pytask/templatetags/browse_helpers.py
--- a/pytask/static/css/base.css	Thu Jan 20 07:56:21 2011 +0530
+++ b/pytask/static/css/base.css	Thu Jan 20 17:42:46 2011 +0530
@@ -278,4 +278,25 @@
   text-align:center;
   font-size: 16px;
   font-weight: bold;
-}
\ No newline at end of file
+}
+
+/* CSS required for tasks and other document pages. */
+div #modification {
+  font-size: small;
+  color: #aa9922;
+  text-align: right;
+}
+
+div #modification a:link,
+div #modification a:visited,
+div #modification a:active {
+  color: #b004fe;
+  font-weight: bold;
+  text-decoration: none;
+}
+
+div #modification a:hover {
+  color: #fb06d0;
+  font-weight: bold;
+  text-decoration: none;
+}
--- a/pytask/templates/task/view_textbook.html	Thu Jan 20 07:56:21 2011 +0530
+++ b/pytask/templates/task/view_textbook.html	Thu Jan 20 17:42:46 2011 +0530
@@ -1,13 +1,16 @@
 {% extends "base.html" %}
 
 {% load form_helpers %}
+{% load browse_helpers %}
+
 
 {% block title %}
     {{textbook.name}}
 {% endblock %}
 
 {% block content %}
-    <h3>{{ textbook.name }}</h3>
+    {% as_modification_display "Created by" textbook.created_by textbook.creation_datetime %}
+    <h3>{{ textbook.title }}</h3>
 
     {% if can_edit %}
         <a href="{% url edit_textbook textbook.id %}">Edit Text book</a>
@@ -17,8 +20,6 @@
         <a href="{% url approve_textbook textbook.id %}">Approve Text book</a>
     {% endif %}
 
-    <hr />created by <a href="{% url view_textbook textbook.created_by.id %}">{{ textbook.created_by.username }}</a>
-    on {{textbook.creation_datetime|date:"D d M Y"}} at {{textbook.creation_datetime|time:"H:i"}}<br />
     <hr />
 
     {% if textbook.tags.count %}
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/pytask/templates/templatetags/_as_modification_display.html	Thu Jan 20 17:42:46 2011 +0530
@@ -0,0 +1,6 @@
+<div id="modification">
+  Created on {{ modification_datetime|date:"r" }} by
+  <a href="{% url view_user_profile user.id %}">
+    {{ user.get_profile.full_name }}
+  </a>
+</div>
\ No newline at end of file
--- a/pytask/templatetags/browse_helpers.py	Thu Jan 20 07:56:21 2011 +0530
+++ b/pytask/templatetags/browse_helpers.py	Thu Jan 20 17:42:46 2011 +0530
@@ -25,11 +25,14 @@
       }
 
 
-@register.inclusion_tag('templatetags/_as_div_field.html')
-def as_div_field(field):
-    """Returns the field for each div form field.
+@register.inclusion_tag('templatetags/_as_modification_display.html')
+def as_modification_display(title, user, creation_datatime):
+    """Returns a context dictionary containing the fields necessary
+    to render the creation/modification
     """
 
     return {
-      'field': field,
+      'title': title,
+      'user': user,
+      'modification_datetime': creation_datatime,
       }