diff -r c9283c3102ce -r b53e1cdb0398 app/soc/views/helper/decorators.py --- a/app/soc/views/helper/decorators.py Thu Jun 04 22:08:11 2009 +0200 +++ b/app/soc/views/helper/decorators.py Thu Jun 04 22:26:24 2009 +0200 @@ -30,10 +30,17 @@ from google.appengine.runtime import DeadlineExceededError from google.appengine.runtime.apiproxy_errors import CapabilityDisabledError - from django import http +from django.utils.translation import ugettext from soc.logic import dicts +from soc.views.helper import responses + + +DEF_DOWN_FOR_MAINTENANCE_MSG = ugettext("Down for maintenance") +DEF_IN_UNEXPECTED_MAINTENANCE_MSG = ugettext( + "Down for unexpected maintenance.") + class Error(Exception): @@ -43,6 +50,31 @@ pass +def maintenance(request): + """Returns a 'down for maintenance' view. + """ + + context = responses.getUniversalContext(request) + context['page_name'] = ugettext('Maintenance') + + notice = context.pop('site_notice') + + if not notice: + context['body_content'] = DEF_IN_UNEXPECTED_MAINTENANCE_MSG + else: + context['body_content'] = notice + + context['header_title'] = DEF_DOWN_FOR_MAINTENANCE_MSG + context['sidebar_menu_items'] = [ + {'heading': DEF_DOWN_FOR_MAINTENANCE_MSG, + 'group': ''}, + ] + + template = 'soc/base.html' + + return responses.respond(request, template, context=context) + + def view(func): """Decorator that insists that exceptions are handled by view. """ @@ -61,11 +93,11 @@ try: site = site_logic.getSingleton() - # don't redirect admins, or if we're at /maintenance already - no_redirect = user_logic.isDeveloper() or request.path == '/maintenance' + # don't redirect admins + redirect = not user_logic.isDeveloper() - if (not no_redirect) and timeline.isActivePeriod(site, 'maintenance'): - return http.HttpResponseRedirect('/maintenance') + if redirect and timeline.isActivePeriod(site, 'maintenance'): + return maintenance(request) return func(request, *args, **kwds) except DeadlineExceededError, exception: