From: hernani Date: Thu, 26 Aug 2010 13:29:28 +0000 (+0000) Subject: A small fix in the admin decorators. X-Git-Tag: live~562 X-Git-Url: https://git.openstreetmap.org./osqa.git/commitdiff_plain/66503d2ac0ba6b217a3ba4af553e2440c9f2421c A small fix in the admin decorators. git-svn-id: http://svn.osqa.net/svnroot/osqa/trunk@572 0cfe37f9-358a-4d5e-be75-b63607b5c754 --- diff --git a/forum/views/admin.py b/forum/views/admin.py index a6a30c0..948f6c5 100644 --- a/forum/views/admin.py +++ b/forum/views/admin.py @@ -34,29 +34,30 @@ def admin_page(fn): @super_user_required def wrapper(request, *args, **kwargs): res = fn(request, *args, **kwargs) - if isinstance(res, tuple): - template, context = res - context['basetemplate'] = settings.DJSTYLE_ADMIN_INTERFACE and "osqaadmin/djstyle_base.html" or "osqaadmin/base.html" - context['allsets'] = Setting.sets - context['othersets'] = sorted( - [s for s in Setting.sets.values() if not s.name in - ('basic', 'users', 'email', 'paths', 'extkeys', 'repgain', 'minrep', 'voting', 'accept', 'badges', 'about', 'faq', 'sidebar', - 'form', 'moderation', 'css', 'headandfoot', 'head', 'view', 'urls')] - , lambda s1, s2: s1.weight - s2.weight) - - context['tools'] = TOOLS - - unsaved = request.session.get('previewing_settings', {}) - context['unsaved'] = set([getattr(settings, s).set.name for s in unsaved.keys() if hasattr(settings, s)]) - - return render_to_response(template, context, context_instance=RequestContext(request)) - else: + if isinstance(res, HttpResponse): return res + template, context = res + context['basetemplate'] = settings.DJSTYLE_ADMIN_INTERFACE and "osqaadmin/djstyle_base.html" or "osqaadmin/base.html" + context['allsets'] = Setting.sets + context['othersets'] = sorted( + [s for s in Setting.sets.values() if not s.name in + ('basic', 'users', 'email', 'paths', 'extkeys', 'repgain', 'minrep', 'voting', 'accept', 'badges', 'about', 'faq', 'sidebar', + 'form', 'moderation', 'css', 'headandfoot', 'head', 'view', 'urls')] + , lambda s1, s2: s1.weight - s2.weight) + + context['tools'] = TOOLS + + unsaved = request.session.get('previewing_settings', {}) + context['unsaved'] = set([getattr(settings, s).set.name for s in unsaved.keys() if hasattr(settings, s)]) + + return render_to_response(template, context, context_instance=RequestContext(request)) + return wrapper def admin_tools_page(name, label): def decorator(fn): + fn = admin_page(fn) fn.label = label TOOLS[name] = fn