From e53b34b80ad5073d78015e4807a8494937ad94fc Mon Sep 17 00:00:00 2001 From: Tom Hughes Date: Sun, 10 Jan 2010 09:16:18 +0000 Subject: [PATCH] Make traces/mine redirect to the user's traces page instead of rendering it itself. Also make sure the traces page for a user includes the upload form if the requestor is logged in as that user. --- app/controllers/trace_controller.rb | 25 ++++++++++++++----------- app/views/trace/_trace_form.html.erb | 4 ++++ app/views/trace/_trace_header.html.erb | 4 ---- app/views/trace/list.html.erb | 4 +++- app/views/trace/mine.html.erb | 3 --- 5 files changed, 21 insertions(+), 19 deletions(-) delete mode 100644 app/views/trace/mine.html.erb diff --git a/app/controllers/trace_controller.rb b/app/controllers/trace_controller.rb index 99f11d546..4c4ec60a7 100644 --- a/app/controllers/trace_controller.rb +++ b/app/controllers/trace_controller.rb @@ -96,20 +96,11 @@ class TraceController < ApplicationController @action = action @display_name = target_user.display_name if target_user @all_tags = tagset.values + @trace = Trace.new(:visibility => default_visibility) if @user end def mine - # Load the preference of whether the user set the trace public the last time - @trace = Trace.new - visibility = @user.preferences.find(:first, :conditions => {:k => "gps.trace.visibility"}) - if visibility - @trace.visibility = visibility.v - elsif @user.preferences.find(:first, :conditions => {:k => "gps.trace.public", :v => "default"}).nil? - @trace.visibility = "private" - else - @trace.visibility = "public" - end - list(@user, "mine") + redirect_to :action => :list, :display_name => @user.display_name end def view @@ -398,4 +389,16 @@ private redirect_to :action => :offline if OSM_STATUS == :gpx_offline end + def default_visibility + visibility = @user.preferences.find(:first, :conditions => {:k => "gps.trace.visibility"}) + + if visibility + visibility.v + elsif @user.preferences.find(:first, :conditions => {:k => "gps.trace.public", :v => "default"}).nil? + "private" + else + "public" + end + end + end diff --git a/app/views/trace/_trace_form.html.erb b/app/views/trace/_trace_form.html.erb index 194b8b2bc..3d93b65e8 100644 --- a/app/views/trace/_trace_form.html.erb +++ b/app/views/trace/_trace_form.html.erb @@ -1,3 +1,7 @@ +<% if @user.traces.count(:conditions => ["inserted=?", false]) > 4 %> +

<%= t'trace.trace_header.traces_waiting', :count => @user.traces.count(:conditions => ["inserted=?", false]) %>

+<% end %> + <% form_for :trace, @trace, :url => { :action => "create" }, :html => { :multipart => true } do |f| %> diff --git a/app/views/trace/_trace_header.html.erb b/app/views/trace/_trace_header.html.erb index 5be7269c2..85de77396 100644 --- a/app/views/trace/_trace_header.html.erb +++ b/app/views/trace/_trace_header.html.erb @@ -16,7 +16,3 @@ | <%= link_to t('trace.trace_header.see_your_traces'), :controller => 'trace', :action => 'mine' %> <% end %>

- -<% if @user and @user.traces.count(:conditions => ["inserted=?", false]) > 4 %> -

<%= t'trace.trace_header.traces_waiting', :count => @user.traces.count(:conditions => ["inserted=?", false]) %>

-<% end %> diff --git a/app/views/trace/list.html.erb b/app/views/trace/list.html.erb index 51752a246..fe7e5a13a 100644 --- a/app/views/trace/list.html.erb +++ b/app/views/trace/list.html.erb @@ -1,3 +1,5 @@ <%= render :partial => 'trace_header' %> - +<% if @user and @user.display_name == @display_name %> + <%= render :partial => 'trace_form' %> +<% end %> <%= render :partial => 'trace_list' %> diff --git a/app/views/trace/mine.html.erb b/app/views/trace/mine.html.erb deleted file mode 100644 index 7deaa1831..000000000 --- a/app/views/trace/mine.html.erb +++ /dev/null @@ -1,3 +0,0 @@ -<%= render :partial => 'trace_header' %> -<%= render :partial => 'trace_form' %> -<%= render :partial => 'trace_list' %> -- 2.39.5
<%= t'trace.trace_form.upload_gpx' %><%= f.file_field :gpx_file, :size => 50, :maxlength => 255 %>