diff options
author | Madhusudan.C.S | 2011-01-20 07:56:21 +0530 |
---|---|---|
committer | Madhusudan.C.S | 2011-01-20 07:56:21 +0530 |
commit | fb87f9cc63ff921bc1dd9d2edc1225cecd7ecf70 (patch) | |
tree | 216d29787eb35c05091663f974d1ab18e98bcf65 | |
parent | ae1ee0967d189ca3a37438bd88d3baec6ed279f5 (diff) | |
download | pytask-fb87f9cc63ff921bc1dd9d2edc1225cecd7ecf70.tar.gz pytask-fb87f9cc63ff921bc1dd9d2edc1225cecd7ecf70.tar.bz2 pytask-fb87f9cc63ff921bc1dd9d2edc1225cecd7ecf70.zip |
List each department textbooks separately for now, think of a clever way later.
-rwxr-xr-x | pytask/taskapp/views.py | 23 | ||||
-rw-r--r-- | pytask/templates/task/browse_textbooks.html | 42 |
2 files changed, 49 insertions, 16 deletions
diff --git a/pytask/taskapp/views.py b/pytask/taskapp/views.py index e383845..f03b6ef 100755 --- a/pytask/taskapp/views.py +++ b/pytask/taskapp/views.py @@ -9,6 +9,7 @@ from django.core.urlresolvers import reverse 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 @@ def browse_textbooks(request): 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 diff --git a/pytask/templates/task/browse_textbooks.html b/pytask/templates/task/browse_textbooks.html index 4bc7104..74eaa41 100644 --- a/pytask/templates/task/browse_textbooks.html +++ b/pytask/templates/task/browse_textbooks.html @@ -1,18 +1,36 @@ {% extends "base.html" %} + +{% load browse_helpers %} + + {% block content %} - {% if open_textbooks %} - Textbooks that are open for contribution - <ul> - {% for textbook in open_textbooks %} - <li> - <a href="{% url view_textbook textbook.id %}"> - {{ textbook.title }} - </a> - </li> - {% endfor %} - </ul> - <br /> + {% if aero_textbooks %} + {% as_list_textbooks aero_textbooks "Aerospace Engineering" %} + {% endif %} + + {% if chemical_textbooks %} + {% as_list_textbooks chemical_textbooks "Chemical Engineering" %} + {% endif %} + + {% if computerscience_textbooks %} + {% as_list_textbooks computerscience_textbooks "Computer Science and Engineering" %} + {% endif %} + + {% if electrical_textbooks %} + {% as_list_textbooks electrical_textbooks "Electrical Engineering" %} + {% endif %} + + {% if engineeringphysics_textbooks %} + {% as_list_textbooks engineeringphysics_textbooks "Engineering Physics Engineering" %} + {% endif %} + + {% if mechanical_textbooks %} + {% as_list_textbooks mechanical_textbooks "Mechanical Engineering" %} + {% endif %} + + {% if metallurgical_textbooks %} + {% as_list_textbooks metallurgical_textbooks "Metallurgical Engineering and Materials Science" %} {% endif %} |