# Counts and selects pages of GPX traces for various criteria (by user, tags, public etc.).
# target_user - if set, specifies the user to fetch traces for. if not set will fetch all traces
- def list(target_user = nil, action = "list")
+ def list
# from display name, pick up user id if one user's traces only
display_name = params[:display_name]
- if target_user.nil? and !display_name.blank?
+ if !display_name.blank?
target_user = User.find(:first, :conditions => { :status => ["active", "confirmed"], :display_name => display_name })
if target_user.nil?
@title = t'trace.no_such_user.title'
end
# final helper vars for view
- @action = action
+ @target_user = target_user
@display_name = target_user.display_name if target_user
@all_tags = tagset.values
@trace = Trace.new(:visibility => default_visibility) if @user
-<% if @user.traces.count(:conditions => ["inserted=?", false]) > 4 %>
- <p><%= t'trace.trace_header.traces_waiting', :count => @user.traces.count(:conditions => ["inserted=?", false]) %></p>
+<% if @target_user.traces.count(:conditions => ["inserted=?", false]) > 4 %>
+ <p><%= t'trace.trace_header.traces_waiting', :count => @target_user.traces.count(:conditions => ["inserted=?", false]) %></p>
<% end %>
<% form_for :trace, @trace, :url => { :action => "create" }, :html => { :multipart => true } do |f| %>
<p>
<%= rss_link_to :action => 'georss', :display_name => @display_name, :tag => @tag %>
- <% if @user.nil? or @display_name.nil? or @user.display_name != @display_name %>
+ <% unless_user(@target_user, :span) do %>
| <%= link_to t('trace.trace_header.see_just_your_traces'), :action => 'mine' %>
<% end %>
- <% if @tag or @display_name %>
- | <%= link_to t('trace.trace_header.see_all_traces'), :controller => 'trace', :action => 'list' %>
- <% end %>
- <% if @tag and @user and @user.display_name == @display_name %>
- | <%= link_to t('trace.trace_header.see_your_traces'), :controller => 'trace', :action => 'mine' %>
+ <% if @tag %>
+ <% if @display_name %>
+ | <%= link_to t('trace.trace_header.see_all_traces'), :controller => 'trace', :action => 'list' %>
+ <% end %>
+ <% if_user(@target_user, :span) do %>
+ | <%= link_to t('trace.trace_header.see_your_traces'), :controller => 'trace', :action => 'mine' %>
+ <% end %>
<% end %>
</p>
<%= render :partial => 'trace_header' %>
-<% if @user and @user.display_name == @display_name %>
+<% if_user(@target_user) do %>
<%= render :partial => 'trace_form' %>
<% end %>
<%= render :partial => 'trace_list' %>
<br /><br />
-<table>
- <tr>
- <% if @trace.user == @user %>
- <td><%= button_to t('trace.view.edit_track'), :controller => 'trace', :action => 'edit', :id => @trace.id %></td>
- <% end %>
- <% if @trace.user == @user %>
- <td><%= button_to t('trace.view.delete_track'), :controller => 'trace', :action => 'delete', :id => @trace.id %></td>
- <% end %>
- </tr>
-</table>
+<% if_user(@trace.user) do %>
+ <table>
+ <tr>
+ <td><%= button_to t('trace.view.edit_track'), :controller => 'trace', :action => 'edit', :id => @trace.id %></td>
+ <td><%= button_to t('trace.view.delete_track'), :controller => 'trace', :action => 'delete', :id => @trace.id %></td>
+ </tr>
+ </table>
+<% end %>