From: Tom Hughes Date: Thu, 26 Jun 2008 17:36:21 +0000 (+0000) Subject: Disable the data browswer when the database is not available. X-Git-Tag: live~7699^2~1 X-Git-Url: https://git.openstreetmap.org/rails.git/commitdiff_plain/abb66fa808f09469306e6b03b21539eb57b74d38 Disable the data browswer when the database is not available. --- diff --git a/app/controllers/application.rb b/app/controllers/application.rb index 7570fd82a..918e4b617 100644 --- a/app/controllers/application.rb +++ b/app/controllers/application.rb @@ -43,8 +43,8 @@ class ApplicationController < ActionController::Base end end - def check_database_availability - if OSM_STATUS == :database_offline + def check_database_availability(need_api = false) + if OSM_STATUS == :database_offline or (need_api and OSM_STATUS == :api_offline) redirect_to :controller => 'site', :action => 'offline' end end diff --git a/app/controllers/browse_controller.rb b/app/controllers/browse_controller.rb index fd482119d..f3a04519c 100644 --- a/app/controllers/browse_controller.rb +++ b/app/controllers/browse_controller.rb @@ -1,7 +1,9 @@ class BrowseController < ApplicationController - before_filter :authorize_web layout 'site' + before_filter :authorize_web + before_filter { |c| c.check_database_availability(true) } + def start end diff --git a/app/views/site/index.rhtml b/app/views/site/index.rhtml index 482ed85b8..2cca4d529 100644 --- a/app/views/site/index.rhtml +++ b/app/views/site/index.rhtml @@ -94,9 +94,11 @@ by the OpenStreetMap project and its contributors. function mapInit(){ map = createMap("map"); + <% unless OSM_STATUS == :api_offline or OSM_STATUS == :database_offline %> map.dataLayer = new OpenLayers.Layer("Data", { "visibility": false }); map.dataLayer.events.register("visibilitychanged", map.dataLayer, toggleData); map.addLayer(map.dataLayer); + <% end %> <% if bbox %> var bbox = new OpenLayers.Bounds(<%= minlon %>, <%= minlat %>, <%= maxlon %>, <%= maxlat %>);