]> git.openstreetmap.org Git - rails.git/blobdiff - app/controllers/trace_controller.rb
Patching better 412 error messages from mis-commit on old api06 branch.
[rails.git] / app / controllers / trace_controller.rb
index 0603567c45a2310291374aa3b7cb4cb460014281..e6c732d2d3b760c29fbb48e4e685a32db37a56f0 100644 (file)
@@ -16,6 +16,11 @@ class TraceController < ApplicationController
     display_name = params[:display_name]
     if target_user.nil? and !display_name.blank?
       target_user = User.find(:first, :conditions => [ "visible = ? and display_name = ?", true, display_name])
     display_name = params[:display_name]
     if target_user.nil? and !display_name.blank?
       target_user = User.find(:first, :conditions => [ "visible = ? and display_name = ?", true, display_name])
+      if target_user.nil?
+        @not_found_user = display_name
+        render :action => 'no_such_user', :status => :not_found
+        return
+      end
     end
 
     # set title
     end
 
     # set title
@@ -52,7 +57,12 @@ class TraceController < ApplicationController
       @tag = params[:tag]
 
       files = Tracetag.find_all_by_tag(params[:tag]).collect { |tt| tt.gpx_id }
       @tag = params[:tag]
 
       files = Tracetag.find_all_by_tag(params[:tag]).collect { |tt| tt.gpx_id }
-      conditions[0] += " AND gpx_files.id IN (#{files.join(',')})"
+
+      if files.length > 0
+        conditions[0] += " AND gpx_files.id IN (#{files.join(',')})"
+      else
+        conditions[0] += " AND 0 = 1"
+      end
     end
     
     conditions[0] += " AND gpx_files.visible = ?"
     end
     
     conditions[0] += " AND gpx_files.visible = ?"
@@ -228,6 +238,7 @@ class TraceController < ApplicationController
 
     if trace.inserted?
       if trace.public? or (@user and @user == trace.user)
 
     if trace.inserted?
       if trace.public? or (@user and @user == trace.user)
+        expires_in 7.days, :private => !trace.public, :public => trace.public
         send_file(trace.large_picture_name, :filename => "#{trace.id}.gif", :type => 'image/gif', :disposition => 'inline')
       else
         render :nothing => true, :status => :forbidden
         send_file(trace.large_picture_name, :filename => "#{trace.id}.gif", :type => 'image/gif', :disposition => 'inline')
       else
         render :nothing => true, :status => :forbidden
@@ -244,6 +255,7 @@ class TraceController < ApplicationController
 
     if trace.inserted?
       if trace.public? or (@user and @user == trace.user)
 
     if trace.inserted?
       if trace.public? or (@user and @user == trace.user)
+        expires_in 7.days, :private => !trace.public, :public => trace.public
         send_file(trace.icon_picture_name, :filename => "#{trace.id}_icon.gif", :type => 'image/gif', :disposition => 'inline')
       else
         render :nothing => true, :status => :forbidden
         send_file(trace.icon_picture_name, :filename => "#{trace.id}_icon.gif", :type => 'image/gif', :disposition => 'inline')
       else
         render :nothing => true, :status => :forbidden