From 720f7b0224eebb2c6ab92c5bf83fbddbf82720b3 Mon Sep 17 00:00:00 2001 From: hernani Date: Wed, 30 Jun 2010 17:27:40 +0000 Subject: [PATCH 1/1] Adapts user views to a more manageable decoration schema. git-svn-id: http://svn.osqa.net/svnroot/osqa/trunk@477 0cfe37f9-358a-4d5e-be75-b63607b5c754 --- forum/modules/decorators.py | 11 +++++------ forum/views/users.py | 7 +++---- 2 files changed, 8 insertions(+), 10 deletions(-) diff --git a/forum/modules/decorators.py b/forum/modules/decorators.py index 48bee43..c7c5640 100644 --- a/forum/modules/decorators.py +++ b/forum/modules/decorators.py @@ -116,13 +116,12 @@ decorate.result = _decorate_result def _decorate_with(fn): def decorator(origin): if not isinstance(origin, DecoratableObject): - mod = inspect.getmodule(origin) - - name = origin.__name__ - origin = DecoratableObject(origin) + decoratable = DecoratableObject(origin) + else: + decoratable = origin - origin._decorate(fn, True, False) - return origin + decoratable._decorate(fn, True, False) + return decoratable return decorator diff --git a/forum/views/users.py b/forum/views/users.py index dd31abb..ba9e173 100644 --- a/forum/views/users.py +++ b/forum/views/users.py @@ -186,7 +186,7 @@ def suspend(request, id): def user_view(template, tab_name, tab_title, tab_description, private=False, tabbed=True, weight=500): def decorator(fn): - def decorated(request, id, slug=None): + def decorated(fn, request, id, slug=None): user = get_object_or_404(User, id=id) if private and not (user == request.user or request.user.is_superuser): return HttpResponseUnauthorized(request) @@ -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 )) - return decorated - + return decorate.withfn(decorated)(fn) return decorator @@ -247,7 +246,7 @@ def user_profile(request, user): "awards": awards, "total_awards" : len(awards), } - + @user_view('users/recent.html', 'recent', _('recent activity'), _('recent user activity')) def user_recent(request, user): activities = user.actions.exclude( -- 2.39.5