# The ChangesetController is the RESTful interface to Changeset objects
class ChangesetController < ApplicationController
+ layout 'site'
require 'xml/libxml'
- session :off
+# session :off
+# FIXME is this required?
+ before_filter :authorize_web, :only => [:list]
before_filter :authorize, :only => [:create, :update, :delete, :upload, :include, :close]
before_filter :check_write_availability, :only => [:create, :update, :delete, :upload, :include]
before_filter :check_read_availability, :except => [:create, :update, :delete, :upload, :download, :query]
render ex.render_opts
end
+ ##
+ # list edits belonging to a user
+ def list
+ user = User.find(:first, :conditions => [ "visible = ? and display_name = ?", true, params[:display_name]])
+ @edit_pages, @edits = paginate(:changesets,
+ :include => [:user, :changeset_tags],
+ :conditions => ["changesets.user_id = ? AND min_lat IS NOT NULL", user.id],
+ :order => "changesets.created_at DESC",
+ :per_page => 20)
+
+ @action = 'list'
+ @display_name = user.display_name
+ # FIXME needs rescues in here
+ end
+
private
#------------------------------------------------------------
# utility functions below.
--- /dev/null
+<tr>
+ <% cl = cycle('table0', 'table1') %>
+
+ <td class="<%= cl %>">
+ #<%= changeset.id %>
+
+ <td class="<%= cl %>">
+ <% if changeset.closed_at > DateTime.now %> (still editing)
+ <% else %><%= changeset.closed_at.strftime("%d %b %Y %H:%M") %><% end %>
+
+ <td class="<%= cl %>">
+ <% if changeset.tags['comment'] %>
+ <%= changeset.tags['comment'] %>
+ <% else %>
+ (none)
+ <% end %>
+
+ <td class="<%= cl %>">
+ <% if changeset.min_lat.nil? %>
+ (no edits)
+ <% else
+ lat1 = changeset.min_lat/GeoRecord::SCALE.to_f
+ lat2 = changeset.max_lat/GeoRecord::SCALE.to_f
+ lon1 = changeset.min_lon/GeoRecord::SCALE.to_f
+ lon2 = changeset.min_lon/GeoRecord::SCALE.to_f
+ %>
+ (<a href='/?lat=<%= lat1 %>&lon=<%= lon1 %>&zoom=14'><%= format("%0.3f",lat1) -%>,<%= format("%0.3f",lon1) -%></a>) to
+ (<a href='/?lat=<%= lat2 %>&lon=<%= lon2 %>&zoom=14'><%= format("%0.3f",lat2) -%>,<%= format("%0.3f",lon2) -%></a>)
+ <% end %>
+
+ <td class="<%= cl %>">
+ <%= link_to 'more', {:controller => 'browse', :action => 'changeset', :id => changeset.id}, {:title => 'View changeset details'} %>
+
+</tr>
--- /dev/null
+<% current_page = @edit_pages.current_page %>
+
+Showing page
+<%= current_page.number %> (<%= current_page.first_item %><%
+if (current_page.first_item < current_page.last_item) # if more than 1 changeset on page
+ %>-<%= current_page.last_item %><%
+end %>
+of <%= @edit_pages.item_count %>)
+
+<% if @edit_pages.page_count > 1 %>
+ | <%= pagination_links_each(@edit_pages, {}) { |n| link_to(n, :display_name => @display_name, :page => n) } %>
+<% end %>
--- /dev/null
+<h1>Edits by <%= link_to(@display_name, {:controller=>'user', :action=>'view', :display_name=>@display_name}) %></h1>
+<%= render :partial => 'changeset_paging_nav' %>
+
+<table id="keyvalue" cellpadding="3">
+ <tr>
+ <th>ID</th>
+ <th>Saved at</th>
+ <th>Comment</th>
+ <th>Area</th>
+ <th></th>
+ </tr>
+ <%= render :partial => 'changeset', :collection => @edits unless @edits.nil? %>
+</table>
+
+<%= render :partial => 'changeset_paging_nav' %>
<!-- Displaying user's own profile page -->
<%= link_to 'my diary', :controller => 'diary_entry', :action => 'list', :display_name => @user.display_name %>
| <%= link_to 'new diary entry', :controller => 'diary_entry', :action => 'new', :display_name => @user.display_name %>
+| <%= link_to 'my edits', :controller => 'changeset', :action => 'list', :display_name => @user.display_name %>
| <%= link_to 'my traces', :controller => 'trace', :action=>'mine' %>
| <%= link_to 'my settings', :controller => 'user', :action => 'account', :display_name => @user.display_name %>
<% else %>
<!-- Displaying another user's profile page -->
<%= link_to 'send message', :controller => 'message', :action => 'new', :user_id => @this_user.id %>
| <%= link_to 'diary', :controller => 'diary_entry', :action => 'list', :display_name => @this_user.display_name %>
+| <%= link_to 'edits', :controller => 'changeset', :action => 'list', :display_name => @this_user.display_name %>
| <%= link_to 'traces', :controller => 'trace', :action => 'view', :display_name => @this_user.display_name %>
| <% if @user and @user.is_friends_with?(@this_user) %>
<%= link_to 'remove as friend', :controller => 'user', :action => 'remove_friend', :display_name => @this_user.display_name %>
# user pages
map.connect '/user/:display_name', :controller => 'user', :action => 'view'
+ map.connect '/user/:display_name/edits', :controller => 'changeset', :action => 'list'
map.connect '/user/:display_name/make_friend', :controller => 'user', :action => 'make_friend'
map.connect '/user/:display_name/remove_friend', :controller => 'user', :action => 'remove_friend'
map.connect '/user/:display_name/diary', :controller => 'diary_entry', :action => 'list'