pytask/taskapp/views.py
changeset 497 6386458d749b
parent 495 773e886d9b80
child 500 42516ec56822
--- a/pytask/taskapp/views.py	Thu Jan 20 07:55:38 2011 +0530
+++ b/pytask/taskapp/views.py	Thu Jan 20 07:56:21 2011 +0530
@@ -9,6 +9,7 @@
 from django.template import RequestContext
 from django.utils import simplejson as json
 
+from tagging.managers import TaggedItem
 from tagging.models import Tag
 
 from pytask.views import show_msg
@@ -493,15 +494,29 @@
 
     user = request.user
 
-    # Fetch all the tasks tagged with Textbook
-    textbooks = taskapp_models.Task.tagged.with_any(['Textbook'])
 
     # Get all the textbooks that are Open.
-    open_textbooks = textbooks.filter(
+    open_textbooks = taskapp_models.Task.objects.filter(
       status=taskapp_models.TASK_STATUS_CHOICES[1][0]).order_by(
       'creation_datetime')
 
-    context = {'open_textbooks': open_textbooks,}
+
+    context = {
+      'aero_textbooks': TaggedItem.objects.get_by_model(
+        open_textbooks, ['Textbook', 'Aerospace']),
+      'chemical_textbooks': TaggedItem.objects.get_by_model(
+        open_textbooks, ['Textbook', 'Chemical']),
+      'computerscience_textbooks': TaggedItem.objects.get_by_model(
+        open_textbooks, ['Textbook', 'ComputerScience']),
+      'electrical_textbooks': TaggedItem.objects.get_by_model(
+        open_textbooks, ['Textbook', 'Electrical']),
+      'engineeringphysics_textbooks': TaggedItem.objects.get_by_model(
+        open_textbooks, ['Textbook', 'EngineeringPhysics']),
+      'mechanical_textbooks': TaggedItem.objects.get_by_model(
+        open_textbooks, ['Mechanical', 'Textbook']),
+      'metallurgical_textbooks': TaggedItem.objects.get_by_model(
+        open_textbooks, ['Textbook', 'Metallurgical']),
+      }
 
     # Nothing
     if user.is_authenticated() and (user.get_profile().role in