]> git.openstreetmap.org Git - osqa.git/commitdiff
A small fix in the admin decorators.
authorhernani <hernani@0cfe37f9-358a-4d5e-be75-b63607b5c754>
Thu, 26 Aug 2010 13:29:28 +0000 (13:29 +0000)
committerhernani <hernani@0cfe37f9-358a-4d5e-be75-b63607b5c754>
Thu, 26 Aug 2010 13:29:28 +0000 (13:29 +0000)
git-svn-id: http://svn.osqa.net/svnroot/osqa/trunk@572 0cfe37f9-358a-4d5e-be75-b63607b5c754

forum/views/admin.py

index a6a30c08677b4f910fbc353bdb654c342d097381..948f6c5f7cc4765d38871e2e9326b5165017f9d8 100644 (file)
@@ -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