]> 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 c90558269a6b0b497c7a8a37275846924494753c..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.).
@@ -46,15 +48,15 @@ class TraceController < ApplicationController
     # 4 - user's traces, not logged in as that user = all user's public traces
     if target_user.nil? # all traces
       if @user
-        conditions = ["(gpx_files.visibility <> 'private' OR gpx_files.user_id = ?)", @user.id] #1
+        conditions = ["(gpx_files.visibility in ('public', 'identifiable') OR gpx_files.user_id = ?)", @user.id] #1
       else
-        conditions  = ["gpx_files.visibility <> 'private'"] #2
+        conditions  = ["gpx_files.visibility in ('public', 'identifiable')"] #2
       end
     else
       if @user and @user == target_user
         conditions = ["gpx_files.user_id = ?", @user.id] #3 (check vs user id, so no join + can't pick up non-public traces by changing name)
       else
-        conditions = ["gpx_files.public <> 'private' AND gpx_files.user_id = ?", target_user.id] #4
+        conditions = ["gpx_files.visibility in ('public', 'identifiable') AND gpx_files.user_id = ?", target_user.id] #4
       end
     end
     
@@ -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
 
@@ -211,7 +213,7 @@ class TraceController < ApplicationController
   end
 
   def georss
-    conditions = ["gpx_files.visibility <> 'private'"]
+    conditions = ["gpx_files.visibility in ('public', 'identifiable')"]
 
     if params[:display_name]
       conditions[0] += " AND users.display_name = ?"
@@ -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