From: Tom Hughes Date: Sat, 12 Dec 2009 13:06:56 +0000 (+0000) Subject: Add ability to take GPX storage offline. X-Git-Tag: live~6390 X-Git-Url: https://git.openstreetmap.org/rails.git/commitdiff_plain/0f5646d7f0e0ccaf3e7b5fd36c9ac4047d5df210 Add ability to take GPX storage offline. --- diff --git a/app/controllers/trace_controller.rb b/app/controllers/trace_controller.rb index 2eaacbf34..9addcbfec 100644 --- a/app/controllers/trace_controller.rb +++ b/app/controllers/trace_controller.rb @@ -11,6 +11,8 @@ class TraceController < ApplicationController before_filter :check_api_writable, :only => [:api_create] before_filter :require_allow_read_gpx, :only => [:api_details, :api_data] before_filter :require_allow_write_gpx, :only => [:api_create] + before_filter :offline_warning, :only => [:mine, :view] + before_filter :offline_redirect, :only => [:create, :edit, :delete, :data, :api_data, :api_create] around_filter :api_call_handle_error, :only => [:api_details, :api_data, :api_create] # Counts and selects pages of GPX traces for various criteria (by user, tags, public etc.). @@ -387,4 +389,12 @@ private end + def offline_warning + flash.now[:warning] = t 'trace.offline_warning.message' if OSM_STATUS == :gpx_offline + end + + def offline_redirect + redirect_to :action => :offline if OSM_STATUS == :gpx_offline + end + end diff --git a/app/views/trace/_trace.html.erb b/app/views/trace/_trace.html.erb index 4cd40352a..696c2045c 100644 --- a/app/views/trace/_trace.html.erb +++ b/app/views/trace/_trace.html.erb @@ -1,10 +1,12 @@ <% cl = cycle('table0', 'table1') %> - <% if trace.inserted %> - - <% else %> - <%= t'trace.trace.pending' %> + <% if OSM_STATUS != :gpx_offline %> + <% if trace.inserted %> + + <% else %> + <%= t'trace.trace.pending' %> + <% end %> <% end %> <%= link_to trace.name, {:controller => 'trace', :action => 'view', :display_name => trace.user.display_name, :id => trace.id} %> diff --git a/app/views/trace/offline.html.erb b/app/views/trace/offline.html.erb new file mode 100644 index 000000000..d9cfb3926 --- /dev/null +++ b/app/views/trace/offline.html.erb @@ -0,0 +1,2 @@ +

<%= t 'trace.offline.heading' %>

+

<%= t 'trace.offline.message' %>

diff --git a/app/views/trace/view.html.erb b/app/views/trace/view.html.erb index 47a9f8ad2..c1d5e0445 100644 --- a/app/views/trace/view.html.erb +++ b/app/views/trace/view.html.erb @@ -1,10 +1,12 @@

<%= t 'trace.view.heading', :name => h(@trace.name) %>

+<% if OSM_STATUS != :gpx_offline %> <% if @trace.inserted %> <% else %> <%= t'trace.view.pending' %> <% end %> +<% end %> diff --git a/config/environment.rb b/config/environment.rb index da2f9b8ac..c26592215 100644 --- a/config/environment.rb +++ b/config/environment.rb @@ -23,6 +23,7 @@ API_VERSION = ENV['OSM_API_VERSION'] || '0.6' # :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 +# :gpx_offline - gpx storage offline # OSM_STATUS = :online diff --git a/config/locales/en.yml b/config/locales/en.yml index 0e3802492..d6547fc78 100644 --- a/config/locales/en.yml +++ b/config/locales/en.yml @@ -1252,6 +1252,11 @@ en: scheduled_for_deletion: "Trace scheduled for deletion" make_public: made_public: "Trace made public" + offline_warning: + message: "The GPX file upload system is currently unavailable" + offline: + heading: "GPX Storage Offline" + message: "The GPX file storage and upload system is currently unavailable." application: require_cookies: cookies_needed: "You appear to have cookies disabled - please enable cookies in your browser before continuing."