# The ChangesetController is the RESTful interface to Changeset objects
class ChangesetController < ApplicationController
+ layout 'site'
require 'xml/libxml'
+ session :off, :except => [:list]
+ 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]
end
end
+ ##
+ # Return XML giving the basic info about the changeset. Does not
+ # return anything about the nodes, ways and relations in the changeset.
def read
begin
changeset = Changeset.find(params[:id])
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.
##
# restrict changes to those which are open
+ #
+ # at the moment this code assumes we're only interested in open
+ # changesets and gives no facility to query closed changesets. this
+ # would be reasonably simple to implement if anyone actually wants
+ # it?
def conditions_open(open)
- return open.nil? ? nil : ['closed_at >= ?', DateTime.now]
+ return open.nil? ? nil : ['closed_at >= ? and num_changes <= ?',
+ DateTime.now, Changeset::MAX_ELEMENTS]
end
end