# HG changeset patch # User Madhusudan.C.S # Date 1295525809 -19800 # Node ID b84d6a1d4603096dea017c95c121d20368265171 # Parent 42516ec56822e9bcd128c034b6aa3ed37a1d4278 Change all the queries to Textbook model to Tasks. Since Textbook model is deprecated now, implemented the changes in the views to query respected queries and make corresponding changes in the views. diff -r 42516ec56822 -r b84d6a1d4603 pytask/taskapp/views.py --- a/pytask/taskapp/views.py Thu Jan 20 17:45:39 2011 +0530 +++ b/pytask/taskapp/views.py Thu Jan 20 17:46:49 2011 +0530 @@ -454,14 +454,24 @@ def view_textbook(request, task_id): - textbook = shortcuts.get_object_or_404(taskapp_models.TextBook, pk=task_id) - chapters = textbook.chapters.all() + # Shortcut to get_object_or_404 is not used since django-tagging + # api expects a queryset object for tag filtering. + task = taskapp_models.Task.objects.filter(pk=task_id) + + textbooks = TaggedItem.objects.get_by_model(task, ['Textbook']) + + if textbooks: + textbook = textbooks[0] + else: + raise http.Http404 + + #chapters = textbook.chapters.all() user = request.user context = {"user": user, "textbook": textbook, - "chapters": chapters, + # "chapters": chapters, } if not user.is_authenticated(): diff -r 42516ec56822 -r b84d6a1d4603 pytask/templates/task/view_textbook.html --- a/pytask/templates/task/view_textbook.html Thu Jan 20 17:45:39 2011 +0530 +++ b/pytask/templates/task/view_textbook.html Thu Jan 20 17:46:49 2011 +0530 @@ -6,7 +6,7 @@ {% block title %} - {{textbook.name}} + {{ textbook.title }} {% endblock %} {% block content %} @@ -31,6 +31,7 @@
{% endif %} + Chapters:
{% if chapters %} {% for chap in chapters %} @@ -41,7 +42,7 @@ {% endfor %}
{% else %} - There are no chapters in this textbook as of now.
+ (Chapters are yet to be added by the Coordinator or T/A.)
{% endif %}