]> git.openstreetmap.org Git - rails.git/blobdiff - app/controllers/trace_controller.rb
this is kind of a "suggested change" for the API controller to
[rails.git] / app / controllers / trace_controller.rb
index 84026e8cd4d420f6f437778df8924db6c6179777..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.).
@@ -117,11 +119,11 @@ class TraceController < ApplicationController
        (@trace.public? or @trace.user == @user)
       @title = t 'trace.view.title', :name => @trace.name
     else
-      flash[:notice] = t 'trace.view.trace_not_found'
+      flash[:error] = t 'trace.view.trace_not_found'
       redirect_to :controller => 'trace', :action => 'list'
     end
   rescue ActiveRecord::RecordNotFound
-    flash[:notice] = t 'trace.view.trace_not_found'
+    flash[:error] = t 'trace.view.trace_not_found'
     redirect_to :controller => 'trace', :action => 'list'
   end
 
@@ -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