]> git.openstreetmap.org Git - rails.git/commitdiff
Merge 14394:14533 from trunk.
authorTom Hughes <tom@compton.nu>
Thu, 16 Apr 2009 21:11:12 +0000 (21:11 +0000)
committerTom Hughes <tom@compton.nu>
Thu, 16 Apr 2009 21:11:12 +0000 (21:11 +0000)
18 files changed:
app/controllers/amf_controller.rb
app/controllers/api_controller.rb
app/controllers/application.rb
app/controllers/browse_controller.rb
app/controllers/diary_entry_controller.rb
app/controllers/message_controller.rb
app/controllers/node_controller.rb
app/controllers/old_node_controller.rb
app/controllers/old_way_controller.rb
app/controllers/relation_controller.rb
app/controllers/swf_controller.rb
app/controllers/trace_controller.rb
app/controllers/user_controller.rb
app/controllers/way_controller.rb
app/views/layouts/site.rhtml
app/views/site/edit.rhtml
app/views/site/offline.rhtml
config/environment.rb

index 1ee5e9cee2b14beacc1552c409694583dd1075c4..de3c7583b42d9977f255a581afbc5fe9265121b2 100644 (file)
@@ -41,7 +41,7 @@ class AmfController < ApplicationController
   include MapBoundary
 
   session :off
-  before_filter :check_write_availability
+  before_filter :check_api_writable
 
   # Main AMF handlers: process the raw AMF string (using AMF library) and
   # calls each action (private method) accordingly.
index f0ba325682c567f400c94d6bd0d398f1f9b9f804..ebf729afc322812002231adeeefe6e486a756367 100644 (file)
@@ -1,7 +1,7 @@
 class ApiController < ApplicationController
 
   session :off
-  before_filter :check_read_availability, :except => [:capabilities]
+  before_filter :check_api_readable, :except => [:capabilities]
   after_filter :compress_output
 
   # Help methods for checking boundary sanity and area size
index f5ea0063db38b76c7d9cdb74b536b1c8f25cd182..21f691bb344c85036cf3681f00af222b3a8c1c2b 100644 (file)
@@ -2,7 +2,7 @@
 # Likewise, all the methods added will be available for all controllers.
 class ApplicationController < ActionController::Base
 
-  if OSM_STATUS == :database_offline
+  if OSM_STATUS == :database_readonly or OSM_STATUS == :database_offline
     session :off
   end
 
@@ -52,13 +52,20 @@ class ApplicationController < ActionController::Base
     end 
   end 
 
-  def check_database_availability(need_api = false)
+  def check_database_readable(need_api = false)
     if OSM_STATUS == :database_offline or (need_api and OSM_STATUS == :api_offline)
       redirect_to :controller => 'site', :action => 'offline'
     end
   end
 
-  def check_read_availability
+  def check_database_writable(need_api = false)
+    if OSM_STATUS == :database_offline or OSM_STATUS == :database_readonly or
+       (need_api and (OSM_STATUS == :api_offline or OSM_STATUS == :api_readonly))
+      redirect_to :controller => 'site', :action => 'offline'
+    end
+  end
+
+  def check_api_readable
     if OSM_STATUS == :database_offline or OSM_STATUS == :api_offline
       response.headers['Error'] = "Database offline for maintenance"
       render :nothing => true, :status => :service_unavailable
@@ -66,8 +73,9 @@ class ApplicationController < ActionController::Base
     end
   end
 
-  def check_write_availability
-    if OSM_STATUS == :database_offline or OSM_STATUS == :api_offline or OSM_STATUS == :api_readonly
+  def check_api_writable
+    if OSM_STATUS == :database_offline or OSM_STATUS == :database_readonly 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
index 465184f5032c59c1a697bf5a2a4d186a4410f1f6..6ace0817b01353a7f1f4a270354b9075c05e5e27 100644 (file)
@@ -2,7 +2,7 @@ class BrowseController < ApplicationController
   layout 'site'
 
   before_filter :authorize_web  
-  before_filter { |c| c.check_database_availability(true) }
+  before_filter { |c| c.check_database_readable(true) }
 
   def start 
   end
index 3592ccb4fb683ce50558ca14dd76580ac9e98fde..3ee36af21a9fb53ac5777344ada62cc4a23bce9e 100644 (file)
@@ -3,7 +3,8 @@ class DiaryEntryController < ApplicationController
 
   before_filter :authorize_web
   before_filter :require_user, :only => [:new, :edit]
-  before_filter :check_database_availability
+  before_filter :check_database_readable
+  before_filter :check_database_writable, :only => [:new, :edit]
 
   def new
     @title = 'New diary entry'
index a04aa82c0c7959e0b504d2a7f0da211a1fde99b7..8f866e512c388fda530304d0da6a84f793268f73 100644 (file)
@@ -3,6 +3,8 @@ class MessageController < ApplicationController
 
   before_filter :authorize_web
   before_filter :require_user
+  before_filter :check_database_readable
+  before_filter :check_database_writable, :only => [:new, :reply, :mark]
 
   # Allow the user to write a new message to another user. This action also 
   # deals with the sending of that message to the other user when the user
index c03f3c4fbf26767135213e4e65c0d2b5de9f11fc..80a3b30d5cfd04d61c24ee5dd7c1723f0b617646 100644 (file)
@@ -5,8 +5,8 @@ class NodeController < ApplicationController
 
   session :off
   before_filter :authorize, :only => [:create, :update, :delete]
-  before_filter :check_write_availability, :only => [:create, :update, :delete]
-  before_filter :check_read_availability, :except => [:create, :update, :delete]
+  before_filter :check_api_writable, :only => [:create, :update, :delete]
+  before_filter :check_api_readable, :except => [:create, :update, :delete]
   after_filter :compress_output
 
   # Create a node from XML.
index 56397625c967490fdd1b365e664bb94588ede6a7..0976a0c9aae87c679bd254b028b45830f9a47077 100644 (file)
@@ -2,7 +2,7 @@ class OldNodeController < ApplicationController
   require 'xml/libxml'
 
   session :off
-  before_filter :check_read_availability
+  before_filter :check_api_readable
   after_filter :compress_output
 
   def history
index da4e26d67be706e07aebd6297b38838ce73f7813..a42496687311d255c3d9c391634f9b6fe55cf728 100644 (file)
@@ -2,7 +2,7 @@ class OldWayController < ApplicationController
   require 'xml/libxml'
 
   session :off
-  before_filter :check_read_availability
+  before_filter :check_api_readable
   after_filter :compress_output
 
   def history
index ec86bb63584c431c0395323da4597d3bec626cfc..3d3fa21858ad35bbba5a0183572adf4e3076d19e 100644 (file)
@@ -3,8 +3,8 @@ class RelationController < ApplicationController
 
   session :off
   before_filter :authorize, :only => [:create, :update, :delete]
-  before_filter :check_write_availability, :only => [:create, :update, :delete]
-  before_filter :check_read_availability, :except => [:create, :update, :delete]
+  before_filter :check_api_writable, :only => [:create, :update, :delete]
+  before_filter :check_api_readable, :except => [:create, :update, :delete]
   after_filter :compress_output
 
   def create
index a96e71d05ee4ef99f9e4ff9e882e29a3fc2d3194..182fb8c549f934291c87f457dd4b069ae24e092a 100644 (file)
@@ -1,6 +1,6 @@
 class SwfController < ApplicationController
        session :off
-       before_filter :check_read_availability
+       before_filter :check_api_readable
 
 # to log:
 # RAILS_DEFAULT_LOGGER.error("Args: #{args[0]}, #{args[1]}, #{args[2]}, #{args[3]}")
index b52be7f349bbb83af740eae7b48a0d5c315919b7..0603567c45a2310291374aa3b7cb4cb460014281 100644 (file)
@@ -4,8 +4,10 @@ class TraceController < ApplicationController
   before_filter :authorize_web
   before_filter :require_user, :only => [:mine, :create, :edit, :delete, :make_public]
   before_filter :authorize, :only => [:api_details, :api_data, :api_create]
-  before_filter :check_database_availability, :except => [:api_details, :api_data, :api_create]
-  before_filter :check_read_availability, :only => [:api_details, :api_data, :api_create]
+  before_filter :check_database_readable, :except => [:api_details, :api_data, :api_create]
+  before_filter :check_database_writable, :only => [:create, :edit, :delete, :make_public]
+  before_filter :check_api_readable, :only => [:api_details, :api_data]
+  before_filter :check_api_writable, :only => [:api_create]
  
   # Counts and selects pages of GPX traces for various criteria (by user, tags, public etc.).
   #  target_user - if set, specifies the user to fetch traces for.  if not set will fetch all traces
index 553e841aa3658af2a3342a09a94be7391097bc44..9544dd8a888c29aa5caf9990360398451b302dda 100644 (file)
@@ -4,8 +4,9 @@ class UserController < ApplicationController
   before_filter :authorize, :only => [:api_details, :api_gpx_files]
   before_filter :authorize_web, :except => [:api_details, :api_gpx_files]
   before_filter :require_user, :only => [:set_home, :account, :go_public, :make_friend, :remove_friend, :upload_image, :delete_image]
-  before_filter :check_database_availability, :except => [:api_details, :api_gpx_files]
-  before_filter :check_read_availability, :only => [:api_details, :api_gpx_files]
+  before_filter :check_database_readable, :except => [:api_details, :api_gpx_files]
+  before_filter :check_database_writable, :only => [:login, :new, :set_home, :account, :go_public, :make_friend, :remove_friend, :upload_image, :delete_image]
+  before_filter :check_api_readable, :only => [:api_details, :api_gpx_files]
 
   filter_parameter_logging :password, :pass_crypt, :pass_crypt_confirmation
 
index 80c75d91c3644d4c72fb04c8ea8758687217fa5a..e28945dcd90d7ad898905bd854b0bd61fe4ebfe6 100644 (file)
@@ -3,8 +3,8 @@ class WayController < ApplicationController
 
   session :off
   before_filter :authorize, :only => [:create, :update, :delete]
-  before_filter :check_write_availability, :only => [:create, :update, :delete]
-  before_filter :check_read_availability, :except => [:create, :update, :delete]
+  before_filter :check_api_writable, :only => [:create, :update, :delete]
+  before_filter :check_api_readable, :except => [:create, :update, :delete]
   after_filter :compress_output
 
   def create
index bc51fa98b3a576eaee6ec6d89ead45607f271da7..534003031a4d9903fc522333b32d6cf2d505632b 100644 (file)
@@ -94,7 +94,7 @@
         The OpenStreetMap database is currently offline while
         essential database maintenance work is carried out.
       </div>
-      <% elsif OSM_STATUS == :api_readonly %>
+      <% elsif OSM_STATUS == :database_readonly or OSM_STATUS == :api_readonly %>
       <div id="alert">
         The OpenStreetMap database is currently in read-only mode while
         essential database maintenance work is carried out.
index daa78f3b9f72bbda47848a991865f07c02037996..e341305f591cad809733c2ca1e14e21f4ceb257c 100644 (file)
@@ -2,7 +2,7 @@
 <p>The OpenStreetMap database is currently offline while
    essential database maintenance work is carried out.
 </p>
-<% elsif OSM_STATUS == :api_readonly %>
+<% elsif OSM_STATUS == :database_readonly or OSM_STATUS == :api_readonly %>
 <p>The OpenStreetMap database is currently in read-only mode while
    essential database maintenance work is carried out.
 </p>
index d97a6ca90cb41a72f071e8e4b7500b0371ef4484..22cf37ca9b1e3e8979b86a123284aa67afafd081 100644 (file)
@@ -1,3 +1,9 @@
+<% if OSM_STATUS == :database_offline %>
 <p>The OpenStreetMap database is currently offline while
    essential database maintenance work is carried out.
 </p>
+<% else %>
+<p>The OpenStreetMap database is currently in read-only mode while
+   essential database maintenance work is carried out.
+</p>
+<% end  %>
index ce1216b83c6966a0c653b69f607b0fb563eb2855..7f83fd4ad7f87670a6b4e17a770bcce4345796e0 100644 (file)
@@ -21,6 +21,7 @@ API_VERSION = ENV['OSM_API_VERSION'] || '0.6'
 #   :online - online and operating normally
 #   :api_readonly - site online but API in read-only mode
 #   :api_offline - site online but API offline
+#   :database_readonly - database and site in read-only mode
 #   :database_offline - database offline with site in emergency mode
 #
 OSM_STATUS = :online