]> git.openstreetmap.org Git - osqa.git/blobdiff - forum/modules/ui_objects.py
Creating my branch
[osqa.git] / forum / modules / ui_objects.py
index 7fcf96caea9ccb155a4854492279f7c5ff452937..e42c94017ce6545cdc70ffbf8187607a71652a98 100644 (file)
@@ -2,6 +2,7 @@ from django.core.urlresolvers import reverse
 from django.template.defaultfilters import slugify
 from django import template
 from forum.utils import html
+from forum.models.user import AnonymousUser
 from ui import Registry
 from copy import copy
 
@@ -62,7 +63,7 @@ class ObjectBase(object):
 
         def __call__(self, context):
             if callable(self.argument):
-                user = context.get('request', None) and context['request'].user or None
+                user = context.get('request', None) and context['request'].user or AnonymousUser()
                 return self.argument(user, context)
             else:
                 return self.argument
@@ -78,7 +79,10 @@ class ObjectBase(object):
         try:
             return self._visible_to(context['request'].user)
         except KeyError:
-            return True
+            try:
+                return self._visible_to(context['viewer'])
+            except KeyError:
+                return self._visible_to(AnonymousUser())
 
     def render(self, context):
         return ''