Display list of tasks related to a Textbook and allow coordinator to create them.
authorMadhusudan.C.S <madhusudancs@gmail.com>
Sun, 30 Jan 2011 20:06:16 +0530
changeset 530 ab9b9e59de9d
parent 529 58b9a98ffbcf
child 531 13eba81f3aa1
Display list of tasks related to a Textbook and allow coordinator to create them.
pytask/taskapp/views.py
pytask/templates/task/view_textbook.html
--- a/pytask/taskapp/views.py	Sun Jan 30 20:05:38 2011 +0530
+++ b/pytask/taskapp/views.py	Sun Jan 30 20:06:16 2011 +0530
@@ -544,14 +544,15 @@
     else:
         raise http.Http404
 
-    #chapters = textbook.chapters.all()
+    chapters = textbook.children_tasks.all()
 
     user = request.user
 
-    context = {"user": user,
-               "textbook": textbook,
-    #           "chapters": chapters,
-              }
+    context = {
+      'user': user,
+      'textbook': textbook,
+      'chapters': chapters,
+      }
 
     if not user.is_authenticated():
         return shortcuts.render_to_response(template,
@@ -572,9 +573,10 @@
       textbook.status in [taskapp_models.TB_STATUS_CHOICES[0][0],
       taskapp_models.TB_STATUS_CHOICES[1][0]]):
         can_edit = True
+        can_create_chapters = True
     else:
         can_edit = False
-
+        can_create_chapters = False
 
     if (profile.role in [profile_models.ROLES_CHOICES[0][0],
       profile_models.ROLES_CHOICES[1][0]] and
--- a/pytask/templates/task/view_textbook.html	Sun Jan 30 20:05:38 2011 +0530
+++ b/pytask/templates/task/view_textbook.html	Sun Jan 30 20:06:16 2011 +0530
@@ -11,7 +11,7 @@
 
 {% block content %}
     {% as_modification_display "Created by" textbook.created_by textbook.creation_datetime %}
-    <h3>{{ textbook.title }}</h3>
+    <h2>{{ textbook.title }}</h2>
 
     {% if can_edit %}
         <a href="{% url edit_textbook textbook.id %}">Edit Text book</a>
@@ -24,20 +24,21 @@
     <hr />
 
     {% if textbook.tags.count %}
-        Tags: 
-        {% for tag in textbook.tags %}
-            {{tag}}
-        {% endfor %}
+        Tags: {{ textbook.tags_field }}
         <hr />
     {% endif %}
 
-    Chapters: <br />
+    <h3>
+      Tasks:
+      {% if can_create_chapters %}
+        <a href="{% url create_chapter textbook.id %}">Create Tasks</a>
+      {% endif %}
+    </h3>
     {% if chapters %}
       <table>
       {% for chap in chapters %}
       <tr>
-  	    <td><a href="{% url view_task chap.id %}">{{chap.title}}</a> </td>
-  	    <td> {{chap.status}} </td>
+        <td><a href="{% url view_task chap.id %}">{{chap.title}}</a> </td>
       </tr>
       {% endfor %}
       </table>
@@ -45,7 +46,7 @@
       (Chapters are yet to be added by the Coordinator or T/A.)<br />
     {% endif %}
 
-        <hr />
+     <hr />
     {% if comments %}
         comments:<br /><br />
         {% for comment in comments %}