- doc.find('//osm/delete/way').each do |nd|
- elem = XML::Node.new 'way'
- way = Way.find(nd['id'])
- way.delete_with_history(@user)
- elem['old_id'] = elem['new_id'] = way.id.to_s
- elem['new_version'] = way.version.to_s
- root << elem
+
+ @page = (params[:page] || 1).to_i
+ @page_size = 20
+
+ @edits = changesets.order("changesets.created_at DESC").offset((@page - 1) * @page_size).limit(@page_size).preload(:user, :changeset_tags)
+
+ render :action => :list
+ end
+ end
+
+ ##
+ # list edits as an atom feed
+ def feed
+ list
+ end
+
+private
+ #------------------------------------------------------------
+ # utility functions below.
+ #------------------------------------------------------------
+
+ ##
+ # if a bounding box was specified do some sanity checks.
+ # restrict changesets to those enclosed by a bounding box
+ # we need to return both the changesets and the bounding box
+ def conditions_bbox(changesets, bbox)
+ if bbox
+ bbox.check_boundaries
+ bbox = bbox.to_scaled
+ return changesets.where("min_lon < ? and max_lon > ? and min_lat < ? and max_lat > ?",
+ bbox.max_lon.to_i, bbox.min_lon.to_i,
+ bbox.max_lat.to_i, bbox.min_lat.to_i)
+ else
+ return changesets
+ end
+ end
+
+ ##
+ # restrict changesets to those by a particular user
+ def conditions_user(changesets, user, name)
+ unless user.nil? and name.nil?
+ # shouldn't provide both name and UID
+ raise OSM::APIBadUserInput.new("provide either the user ID or display name, but not both") if user and name
+
+ # use either the name or the UID to find the user which we're selecting on.
+ u = if name.nil?
+ # user input checking, we don't have any UIDs < 1
+ raise OSM::APIBadUserInput.new("invalid user ID") if user.to_i < 1
+ u = User.find(user.to_i)
+ else
+ u = User.find_by_display_name(name)
+ end
+
+ # make sure we found a user
+ raise OSM::APINotFoundError.new if u.nil?
+
+ # should be able to get changesets of public users only, or
+ # our own changesets regardless of public-ness.
+ unless u.data_public?
+ # get optional user auth stuff so that users can see their own
+ # changesets if they're non-public
+ setup_user_auth
+
+ raise OSM::APINotFoundError if @user.nil? or @user.id != u.id