]> git.openstreetmap.org Git - rails.git/commitdiff
Remember whether the user set the public checkbox on GPX upload as a user preference...
authorShaun McDonald <shaun@shaunmcdonald.me.uk>
Tue, 18 Nov 2008 20:22:09 +0000 (20:22 +0000)
committerShaun McDonald <shaun@shaunmcdonald.me.uk>
Tue, 18 Nov 2008 20:22:09 +0000 (20:22 +0000)
app/controllers/trace_controller.rb
app/models/user.rb

index d94280a6af080c469a2662212382e340e05c4387..06ae5dc3b7e1910d6614295d9f5e791b0ec876dc 100644 (file)
@@ -79,6 +79,12 @@ class TraceController < ApplicationController
 
   def mine
     if @user
+      @trace = Trace.new
+      unless @user.trace_public_default.nil?
+        @trace.public = true
+      else 
+        @trace.public = false
+      end
       list(@user, "mine") unless @user.nil?
     else
       redirect_to :controller => 'user', :action => 'login', :referer => request.request_uri
@@ -312,6 +318,17 @@ private
     else
       FileUtils.rm_f(filename)
     end
+    
+    # Finally save whether the user marked the trace as being public
+    if @trace.public?
+      if @user.trace_public_default.nil?
+        @user.preferences.create(:k => "gps.trace.public", :v => "default")
+      end
+    else
+      pref = @user.trace_public_default
+      pref.destroy unless pref.nil?
+    end
+    
   end
 
 end
index ecf41fd18fb827d4f56aee783416db627205f5f5..0eddb259d01213506df8aa502aa71076b0a669aa 100644 (file)
@@ -106,4 +106,8 @@ class User < ActiveRecord::Base
     return false
   end
 
+  def trace_public_default
+    return self.preferences.find(:first, :conditions => {:k => "gps.trace.public", :v => "default"})
+  end
+
 end