From: Shaun McDonald Date: Tue, 18 Nov 2008 20:22:09 +0000 (+0000) Subject: Remember whether the user set the public checkbox on GPX upload as a user preference... X-Git-Tag: live~8182^2~137 X-Git-Url: https://git.openstreetmap.org./rails.git/commitdiff_plain/55d511bf21dfc4e1b7d0666a2a547b1d3c3845b0 Remember whether the user set the public checkbox on GPX upload as a user preference. Closes #827 --- diff --git a/app/controllers/trace_controller.rb b/app/controllers/trace_controller.rb index d94280a6a..06ae5dc3b 100644 --- a/app/controllers/trace_controller.rb +++ b/app/controllers/trace_controller.rb @@ -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 diff --git a/app/models/user.rb b/app/models/user.rb index ecf41fd18..0eddb259d 100644 --- a/app/models/user.rb +++ b/app/models/user.rb @@ -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