diff gpp/forums/views/favorites.py @ 459:9d3bd7304050

Fixing #221. Also combined all permissions checks into a new module, permissions.py. This allows us to cache user, category, and forum groups information since it rarely changes.
author Brian Neal <bgneal@gmail.com>
date Sat, 02 Jul 2011 23:35:45 +0000
parents b2b37cdd020a
children
line wrap: on
line diff
--- a/gpp/forums/views/favorites.py	Sat Jul 02 03:52:43 2011 +0000
+++ b/gpp/forums/views/favorites.py	Sat Jul 02 23:35:45 2011 +0000
@@ -13,6 +13,7 @@
 
 from core.paginator import DiggPaginator
 from forums.models import Topic
+import forums.permissions as perms
 
 
 @login_required
@@ -23,11 +24,11 @@
     user.
     """
     topic = get_object_or_404(Topic.objects.select_related(), id=topic_id)
-    if topic.forum.category.can_access(request.user):
+    if perms.can_access(topic.forum.category, request.user):
         topic.bookmarkers.add(request.user)
         return HttpResponseRedirect(
             reverse("forums-favorites_status", args=[topic.id]))
-    raise Http404   # TODO return HttpResponseForbidden instead
+    return HttpResponseForbidden()
 
 
 @login_required