From 55d511bf21dfc4e1b7d0666a2a547b1d3c3845b0 Mon Sep 17 00:00:00 2001 From: Shaun McDonald Date: Tue, 18 Nov 2008 20:22:09 +0000 Subject: [PATCH] Remember whether the user set the public checkbox on GPX upload as a user preference. Closes #827 --- app/controllers/trace_controller.rb | 17 +++++++++++++++++ app/models/user.rb | 4 ++++ 2 files changed, 21 insertions(+) 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 -- 2.39.5