aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--app/controllers/application_controller.rb10
-rw-r--r--app/controllers/comment_controller.rb1
-rw-r--r--app/controllers/request_controller.rb1
-rw-r--r--config/general-example5
4 files changed, 17 insertions, 0 deletions
diff --git a/app/controllers/application_controller.rb b/app/controllers/application_controller.rb
index 1addc5bab..0e01ac149 100644
--- a/app/controllers/application_controller.rb
+++ b/app/controllers/application_controller.rb
@@ -175,6 +175,16 @@ class ApplicationController < ActionController::Base
end
end
+ #
+ def check_read_only
+ read_only = MySociety::Config.get('READ_ONLY')
+ if read_only
+ flash[:notice] = "<p>WhatDoTheyKnow is currently in maintenance. You can only view existing requests. You cannot make new ones, add followups or annotations, or otherwise change the database.</p> <p>" + read_only + "</p>"
+ redirect_to frontpage_url
+ end
+
+ end
+
# For administration interface, return display name of authenticated user
def admin_http_auth_user
# This needs special magic in mongrel: http://www.ruby-forum.com/topic/83067
diff --git a/app/controllers/comment_controller.rb b/app/controllers/comment_controller.rb
index dfa31f9ef..d5f8f89fb 100644
--- a/app/controllers/comment_controller.rb
+++ b/app/controllers/comment_controller.rb
@@ -7,6 +7,7 @@
# $Id: comment_controller.rb,v 1.9 2009-03-09 01:17:04 francis Exp $
class CommentController < ApplicationController
+ before_filter :check_read_only, :only => [ :new ]
def new
if params[:type] == 'request'
diff --git a/app/controllers/request_controller.rb b/app/controllers/request_controller.rb
index 6488ad726..eaed31213 100644
--- a/app/controllers/request_controller.rb
+++ b/app/controllers/request_controller.rb
@@ -7,6 +7,7 @@
# $Id: request_controller.rb,v 1.192 2009-10-19 19:26:40 francis Exp $
class RequestController < ApplicationController
+ before_filter :check_read_only, :only => [ :new, :show_response, :describe_state ]
def show
# Look up by old style numeric identifiers
diff --git a/config/general-example b/config/general-example
index 70345400d..0db548fd6 100644
--- a/config/general-example
+++ b/config/general-example
@@ -47,4 +47,9 @@ define('OPTION_COOKIE_STORE_SESSION_SECRET', 'your secret key here, make it long
define('OPTION_RECAPTCHA_PUBLIC_KEY', 'x');
define('OPTION_RECAPTCHA_PRIVATE_KEY', 'x');
+// If present, puts the site in read only mode, and uses the text as reason
+// (whole paragraph). Please use a read-only database user as well, as it only
+// checks in a few obvious places.
+define('OPTION_READ_ONLY', '');
+
?>