]> git.openstreetmap.org Git - osqa.git/commitdiff
Adapts user views to a more manageable decoration schema.
authorhernani <hernani@0cfe37f9-358a-4d5e-be75-b63607b5c754>
Wed, 30 Jun 2010 17:27:40 +0000 (17:27 +0000)
committerhernani <hernani@0cfe37f9-358a-4d5e-be75-b63607b5c754>
Wed, 30 Jun 2010 17:27:40 +0000 (17:27 +0000)
git-svn-id: http://svn.osqa.net/svnroot/osqa/trunk@477 0cfe37f9-358a-4d5e-be75-b63607b5c754

forum/modules/decorators.py
forum/views/users.py

index 48bee43ce5994032d3454e79090eafbc939ac039..c7c564030adafdb8263ca922e6eb85144625cda4 100644 (file)
@@ -116,13 +116,12 @@ decorate.result = _decorate_result
 def _decorate_with(fn):\r
     def decorator(origin):\r
         if not isinstance(origin, DecoratableObject):\r
-            mod = inspect.getmodule(origin)\r
-\r
-            name = origin.__name__\r
-            origin = DecoratableObject(origin)\r
+            decoratable = DecoratableObject(origin)\r
+        else:\r
+            decoratable = origin\r
 \r
-        origin._decorate(fn, True, False)\r
-        return origin\r
+        decoratable._decorate(fn, True, False)\r
+        return decoratable\r
     return decorator\r
 \r
 \r
index dd31abb7fadf569f936abdc2fc73dbb78199edf2..ba9e1734bb22a49fcc7413f455386d270a764dde 100644 (file)
@@ -186,7 +186,7 @@ def suspend(request, id):
 \r
 def user_view(template, tab_name, tab_title, tab_description, private=False, tabbed=True, weight=500):\r
     def decorator(fn):\r
-        def decorated(request, id, slug=None):\r
+        def decorated(fn, request, id, slug=None):\r
             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
@@ -213,8 +213,7 @@ def user_view(template, tab_name, tab_title, tab_description, private=False, tab
                 tab_name, tab_title, tab_description,url_getter, private, weight\r
             ))\r
 \r
-        return decorated\r
-\r
+        return decorate.withfn(decorated)(fn)\r
     return decorator\r
 \r
 \r
@@ -247,7 +246,7 @@ def user_profile(request, user):
     "awards": awards,\r
     "total_awards" : len(awards),\r
     }\r
-\r
+    \r
 @user_view('users/recent.html', 'recent', _('recent activity'), _('recent user activity'))\r
 def user_recent(request, user):\r
     activities = user.actions.exclude(\r