# HG changeset patch # User Sverre Rabbelier # Date 1235937654 0 # Node ID 4484186d74275879194225eb468f86c1d28d4ca2 # Parent 947a0ee153a48b6c50452e53a21cdc2fe982afd9 Added a maintenance page Currently not used, except when navigating to /maintenance. Patch by: Sverre Rabbelier diff -r 947a0ee153a4 -r 4484186d7427 app/soc/views/models/site.py --- a/app/soc/views/models/site.py Sun Mar 01 20:00:23 2009 +0000 +++ b/app/soc/views/models/site.py Sun Mar 01 20:00:54 2009 +0000 @@ -31,6 +31,7 @@ from soc.views import out_of_band from soc.views.helper import access from soc.views.helper import redirects +from soc.views.helper import responses from soc.views.helper import widgets from soc.views.models import document as document_view from soc.views.models import presence_with_tos @@ -44,6 +45,10 @@ """View methods for the Document model. """ + DEF_DOWN_FOR_MAINTENANCE_MSG = ugettext("Down for maintenance") + DEF_NOT_IN_MAINTENANCE_MSG = ugettext( + "The site is currently not in maintenance mode.") + def __init__(self, params=None): """Defines the fields and methods required for the base View class to provide the user with list, public, create, edit and delete views. @@ -96,6 +101,10 @@ patterns += [(r'^$', 'soc.views.models.%(module_name)s.main_public', page_name)] + page_name = "Maintenance" + patterns += [(r'^maintenance$', 'soc.views.models.%(module_name)s.maintenance', + page_name)] + page_name = "Edit Site" patterns += [(r'^%(url_name)s/(?Pedit)$', 'soc.views.models.%(module_name)s.main_edit', @@ -141,6 +150,29 @@ params = dicts.merge(params, new_params) return super(View, self).getSidebarMenus(id, user, params=params) + def maintenance(self, request, page_name): + """Returns a 'down for maintenance' view. + """ + + context = responses.getUniversalContext(request) + context['page_name'] = page_name + + notice = context.pop('site_notice') + + if not notice: + context['body_content'] = self.DEF_NOT_IN_MAINTENANCE_MSG + else: + context['body_content'] = notice + context['header_title'] = self.DEF_DOWN_FOR_MAINTENANCE_MSG + context['sidebar_menu_items'] = [ + {'heading': self.DEF_DOWN_FOR_MAINTENANCE_MSG, + 'group': ''}, + ] + + template = 'soc/base.html' + + return responses.respond(request, template, context=context) + def mainPublic(self, request, page_name=None, **kwargs): """Displays the main site settings page. @@ -189,4 +221,5 @@ export = view.export main_public = view.mainPublic main_edit = view.mainEdit +maintenance = view.maintenance home = view.home