to be suppressed.
include Potlatch
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.
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
# 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
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
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
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'
before_filter :authorize_web
before_filter :require_user
+ before_filter :check_database_readable
+ before_filter :check_database_writable, :only => [:new, :reply, :mark]
def new
@title = 'send message'
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_writeable, :only => [:create, :update, :delete]
+ before_filter :check_api_readable, :except => [:create, :update, :delete]
after_filter :compress_output
# Create a node from XML.
require 'xml/libxml'
session :off
- before_filter :check_read_availability
+ before_filter :check_api_readable
after_filter :compress_output
def history
require 'xml/libxml'
session :off
- before_filter :check_read_availability
+ before_filter :check_api_readable
after_filter :compress_output
def history
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_writeable, :only => [:create, :update, :delete]
+ before_filter :check_api_readable, :except => [:create, :update, :delete]
after_filter :compress_output
def create
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]}")
before_filter :authorize_web
before_filter :require_user, :only => [:mine, :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
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
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_writeable, :only => [:create, :update, :delete]
+ before_filter :check_api_readable, :except => [:create, :update, :delete]
after_filter :compress_output
def create
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.
<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>
+<% 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 %>
# :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