+ if request.user.is_authenticated() and (request.user.is_staff or request.user.is_superuser):
+ return fn(request, *args, **kwargs)
+ else:
+ return HttpResponseUnauthorized(request)
+
+ return wrapper
+
+def admin_page_wrapper(fn, request, *args, **kwargs):
+ res = fn(request, *args, **kwargs)
+ 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)