Merge 14394:14533 from trunk.
This commit is contained in:
commit
5449cf4adc
18 changed files with 45 additions and 24 deletions
|
@ -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.
|
||||
|
|
|
@ -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
|
||||
|
|
|
@ -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
|
||||
|
|
|
@ -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
|
||||
|
|
|
@ -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'
|
||||
|
|
|
@ -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
|
||||
|
|
|
@ -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.
|
||||
|
|
|
@ -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
|
||||
|
|
|
@ -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
|
||||
|
|
|
@ -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
|
||||
|
|
|
@ -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]}")
|
||||
|
|
|
@ -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
|
||||
|
|
|
@ -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
|
||||
|
||||
|
|
|
@ -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
|
||||
|
|
|
@ -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.
|
||||
|
|
|
@ -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>
|
||||
|
|
|
@ -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 %>
|
||||
|
|
|
@ -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
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue