]> git.openstreetmap.org Git - rails.git/blobdiff - app/controllers/application.rb
Merge 8377:8381 from trunk.
[rails.git] / app / controllers / application.rb
index d22ed5c9f5d17154815873d93c238def19e6fbd5..7570fd82a072d2af2d2e70dd0e33cd2d83df391d 100644 (file)
@@ -2,6 +2,10 @@
 # Likewise, all the methods added will be available for all controllers.
 class ApplicationController < ActionController::Base
 
+  if OSM_STATUS == :database_offline
+    session :off
+  end
+
   def authorize_web
     if session[:user]
       @user = User.find(session[:user])
@@ -39,8 +43,22 @@ class ApplicationController < ActionController::Base
     end 
   end 
 
-  def check_availability
-    if API_READONLY
+  def check_database_availability
+    if OSM_STATUS == :database_offline
+      redirect_to :controller => 'site', :action => 'offline'
+    end
+  end
+
+  def check_read_availability
+    if OSM_STATUS == :database_offline or OSM_STATUS == :api_offline
+      response.headers['Error'] = "Database offline for maintenance"
+      render :nothing => true, :status => :service_unavailable
+      return false
+    end
+  end
+
+  def check_write_availability
+    if OSM_STATUS == :database_offline or OSM_STATUS == :api_offline or OSM_STATUS == :api_readonly
       response.headers['Error'] = "Database offline for maintenance"
       render :nothing => true, :status => :service_unavailable
       return false