]> git.openstreetmap.org Git - osqa.git/commitdiff
Some simple fixes on ui objects to prevent missing request in the context problem.
authorhernani <hernani@0cfe37f9-358a-4d5e-be75-b63607b5c754>
Mon, 5 Jul 2010 22:21:06 +0000 (22:21 +0000)
committerhernani <hernani@0cfe37f9-358a-4d5e-be75-b63607b5c754>
Mon, 5 Jul 2010 22:21:06 +0000 (22:21 +0000)
git-svn-id: http://svn.osqa.net/svnroot/osqa/trunk@488 0cfe37f9-358a-4d5e-be75-b63607b5c754

forum/modules/ui_objects.py
forum/views/users.py

index 7fcf96caea9ccb155a4854492279f7c5ff452937..e7f626fb417797115d9ee4f4ace5681e2a066d40 100644 (file)
@@ -78,7 +78,13 @@ class ObjectBase(object):
         try:
             return self._visible_to(context['request'].user)
         except KeyError:
-            return True
+            try:
+                return self._visible_to(context['viewer'])
+            except KeyError:
+                if self.visibility:
+                    return False
+                else:
+                    return True
 
     def render(self, context):
         return ''
index 4222acf98d8cd82b493f467e296581ba8e21ac16..2bda26368c419bf75cd5f64a66bcb257ed8ddef0 100644 (file)
@@ -200,6 +200,10 @@ def user_view(template, tab_name, tab_title, tab_description, private=False, tab
             user = get_object_or_404(User, id=id)\r
             if private and not (user == request.user or request.user.is_superuser):\r
                 return HttpResponseUnauthorized(request)\r
+\r
+            if render_to and (not render_to(user)):\r
+                return HttpResponseRedirect(user.get_profile_url())\r
+                \r
             context = fn(request, user)\r
 \r
             rev_page_title = user.username + " - " + tab_description\r