]> git.openstreetmap.org Git - rails.git/blobdiff - app/controllers/trace_controller.rb
Migration to add close-time to changesets. This replaces the boolean 'open' attribute...
[rails.git] / app / controllers / trace_controller.rb
index f0e1fe7cc3881cbc9295a92ffc61b9036124210c..d94280a6af080c469a2662212382e340e05c4387 100644 (file)
@@ -12,7 +12,7 @@ class TraceController < ApplicationController
     # from display name, pick up user id if one user's traces only
     display_name = params[:display_name]
     if target_user.nil? and !display_name.blank?
     # from display name, pick up user id if one user's traces only
     display_name = params[:display_name]
     if target_user.nil? and !display_name.blank?
-      target_user = User.find(:first, :conditions => [ "visible = 1 and display_name = ?", display_name])
+      target_user = User.find(:first, :conditions => [ "visible = ? and display_name = ?", true, display_name])
     end
 
     # set title
     end
 
     # set title
@@ -33,15 +33,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
     # 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.public = 1 OR gpx_files.user_id = ?)", @user.id] #1
+        conditions = ["(gpx_files.public = ? OR gpx_files.user_id = ?)", true, @user.id] #1
       else
       else
-        conditions  = ["gpx_files.public = 1"] #2
+        conditions  = ["gpx_files.public = ?", true] #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
       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 = 1 AND gpx_files.user_id = ?", target_user.id] #4
+        conditions = ["gpx_files.public = ? AND gpx_files.user_id = ?", true, target_user.id] #4
       end
     end
     
       end
     end
     
@@ -51,7 +51,8 @@ class TraceController < ApplicationController
       conditions << @tag
     end
     
       conditions << @tag
     end
     
-    conditions[0] += " AND gpx_files.visible = 1"
+    conditions[0] += " AND gpx_files.visible = ?"
+    conditions << true
 
     @trace_pages, @traces = paginate(:traces,
                                      :include => [:user, :tags],
 
     @trace_pages, @traces = paginate(:traces,
                                      :include => [:user, :tags],
@@ -196,7 +197,7 @@ class TraceController < ApplicationController
   end
 
   def georss
   end
 
   def georss
-    conditions = ["gpx_files.public = 1"]
+    conditions = ["gpx_files.public = ?", true]
 
     if params[:display_name]
       conditions[0] += " AND users.display_name = ?"
 
     if params[:display_name]
       conditions[0] += " AND users.display_name = ?"
@@ -306,9 +307,10 @@ private
     @trace.user = @user
     @trace.timestamp = Time.now
 
     @trace.user = @user
     @trace.timestamp = Time.now
 
-    FileUtils.mv(filename, @trace.trace_name)
-    unless @trace.save
-      FileUtils.rm_f(@trace.trace_name)
+    if @trace.save
+      FileUtils.mv(filename, @trace.trace_name)
+    else
+      FileUtils.rm_f(filename)
     end
   end
 
     end
   end