fixed a bug where guest users were not able to view the page correctly
authorNishanth Amuluru <nishanth@fossee.in>
Wed, 12 Jan 2011 00:22:27 +0530
changeset 387 32dd15eaf9d0
parent 386 026f2059a97a
child 389 a25800ef4217
fixed a bug where guest users were not able to view the page correctly
pytask/taskapp/views.py
--- a/pytask/taskapp/views.py	Wed Jan 12 00:19:22 2011 +0530
+++ b/pytask/taskapp/views.py	Wed Jan 12 00:22:27 2011 +0530
@@ -449,30 +449,33 @@
 
     textbook = getTextBook(tid)
     textbook_url = "/task/textbook/view/tid=%s"%textbook.uniq_key
+    chapters = textbook.chapters.all()
 
     user = request.user
+
+    context = {"user": user,
+               "textbook": textbook,
+               "chapters": chapters,
+              }
+
     if not user.is_authenticated():
-        return render_to_response("task/view_textbook.html", {"user": user})
+        return render_to_response("task/view_textbook.html", context)
 
     profile = user.get_profile()
 
-    context = {"user": user,
-               "profile": profile,
-               "textbook": textbook,
-              }
+    context.update({"profile": profile,
+                    "textbook": textbook,
+                   })
 
     context.update(csrf(request))
 
-    chapters = Task.objects.filter(status="UP")
-
     can_edit = True if user == textbook.created_by and textbook.status == "UP"\
                        else False
 
     can_approve = True if profile.rights in ["MG", "DC"] and \
                           textbook.status == "UP" else False
 
-    context.update({"chapters": chapters,
-                    "can_edit": can_edit,
+    context.update({"can_edit": can_edit,
                     "can_approve": can_approve})
     return render_to_response("task/view_textbook.html", context)