]> git.openstreetmap.org Git - rails.git/commitdiff
Add ability to take GPX storage offline.
authorTom Hughes <tom@compton.nu>
Sat, 12 Dec 2009 13:06:56 +0000 (13:06 +0000)
committerTom Hughes <tom@compton.nu>
Sat, 12 Dec 2009 13:06:56 +0000 (13:06 +0000)
app/controllers/trace_controller.rb
app/views/trace/_trace.html.erb
app/views/trace/offline.html.erb [new file with mode: 0644]
app/views/trace/view.html.erb
config/environment.rb
config/locales/en.yml

index 2eaacbf34fc2296161116511b6e6e763f97b6282..9addcbfec85b4ac34f664c145d084a7bc07097d1 100644 (file)
@@ -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
index 4cd40352a456849e1ad91a4da5776dd99e194255..696c2045c720e56a914e1e05a334912ee2eaec41 100644 (file)
@@ -1,10 +1,12 @@
 <tr>
   <% cl = cycle('table0', 'table1') %>
   <td class="<%= cl %>">
-    <% if trace.inserted %>
-      <a href="<%= url_for :controller => 'trace', :action => 'view', :id => trace.id, :display_name => trace.user.display_name %>"><img src="<%= url_for :controller => 'trace', :action => 'icon', :id => trace.id, :display_name => trace.user.display_name %>" border="0" alt="" /></a>
-    <% else %>
-      <span style="color:red"><%= t'trace.trace.pending' %></span>
+    <% if OSM_STATUS != :gpx_offline %>
+      <% if trace.inserted %>
+        <a href="<%= url_for :controller => 'trace', :action => 'view', :id => trace.id, :display_name => trace.user.display_name %>"><img src="<%= url_for :controller => 'trace', :action => 'icon', :id => trace.id, :display_name => trace.user.display_name %>" border="0" alt="" /></a>
+      <% else %>
+        <span style="color:red"><%= t'trace.trace.pending' %></span>
+      <% end %>
     <% end %>
   </td>
   <td class="<%= cl %>"><%= 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 (file)
index 0000000..d9cfb39
--- /dev/null
@@ -0,0 +1,2 @@
+<h2><%= t 'trace.offline.heading' %></h2>
+<p><%= t 'trace.offline.message' %></p>
index 47a9f8ad22f1f4fed9f8cea05252fefd4ece282a..c1d5e044570f1b1b197fa62e284f3a69525cb3db 100644 (file)
@@ -1,10 +1,12 @@
 <h2><%= t 'trace.view.heading', :name => h(@trace.name) %></h2>
 
+<% if OSM_STATUS != :gpx_offline %>
   <% if @trace.inserted %>
     <img src="<%= url_for :controller => 'trace', :action => 'picture', :id => @trace.id, :display_name => @trace.user.display_name %>">
   <% else %>
     <span style="color:red"><%= t'trace.view.pending' %></span>
   <% end %>
+<% end %>
 
 <table border="0">
   <tr>
index da2f9b8ac787fa957d6ea76b79c136514f30a925..c26592215e921a0373879c72d01f5942a4b3a2ba 100644 (file)
@@ -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
 
index 0e38024926216109d02a423b1f6310af39d9d6db..d6547fc7889d02c1226305682b7e0cef44f04468 100644 (file)
@@ -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."