]> git.openstreetmap.org Git - rails.git/blobdiff - app/controllers/trace_controller.rb
Replace various Leaflet extensions with new builtin methods
[rails.git] / app / controllers / trace_controller.rb
index 05f97bf0d507a667973fbf6405263af44d328c53..c4467159d7726d7f82391c058f788d4f719bdcfd 100644 (file)
@@ -16,12 +16,6 @@ class TraceController < ApplicationController
   before_filter :offline_redirect, :only => [:create, :edit, :delete, :data, :api_create, :api_delete, :api_data]
   around_filter :api_call_handle_error, :only => [:api_create, :api_read, :api_update, :api_delete, :api_data]
 
-  caches_action :list, :unless => :logged_in?, :layout => false
-  caches_action :view, :layout => false
-  caches_action :georss, :layout => true
-  cache_sweeper :trace_sweeper, :only => [:create, :edit, :delete, :api_create, :api_update, :api_delete]
-  cache_sweeper :tracetag_sweeper, :only => [:create, :edit, :delete, :api_create, :api_update, :api_delete]
-
   # Counts and selects pages of GPX traces for various criteria (by user, tags, public etc.).
   #  target_user - if set, specifies the user to fetch traces for.  if not set will fetch all traces
   def list
@@ -66,13 +60,7 @@ class TraceController < ApplicationController
     end
 
     if params[:tag]
-      @tag = params[:tag]
-
-      files = Tracetag.where(:tag => params[:tag]).select(:gpx_id).all
-
-      if files.length > 0
-        @traces = @traces.where(:id => files.collect { |tt| tt.gpx_id })
-      end
+      @traces = @traces.tagged(params[:tag])
     end
 
     @page = (params[:page] || 1).to_i
@@ -215,14 +203,14 @@ class TraceController < ApplicationController
   end
 
   def georss
-    traces = Trace.public
+    traces = Trace.public.visible
 
     if params[:display_name]
       traces = traces.joins(:user).where(:users => {:display_name => params[:display_name]})
     end
 
     if params[:tag]
-      traces = traces.where("EXISTS (SELECT * FROM gpx_file_tags AS gft WHERE gft.gpx_id = gpx_files.id AND gft.tag = ?)", params[:tag])
+      traces = traces.tagged(params[:tag])
     end
 
     traces = traces.order("timestamp DESC")
@@ -368,7 +356,7 @@ private
     filename = "/tmp/#{rand}"
 
     # ...and save the uploaded file to that location
-    File.open(filename, "w") { |f| f.write(file.read) }
+    File.open(filename, "wb") { |f| f.write(file.read) }
 
     # Create the trace object, falsely marked as already
     # inserted to stop the import daemon trying to load it