- Changeset.transaction do
- doc.find('//osm/create/node').each do |nd|
- elem = XML::Node.new 'node'
- node = Node.from_xml_node(nd, true)
- elem['old_id'] = nd['id']
- create_prim node_ids, node, nd
- elem['new_id'] = node.id.to_s
- elem['new_version'] = node.version.to_s
- root << elem
+ # create the results document
+ results = OSM::API.new.get_xml_doc
+
+ # add all matching changesets to the XML results document
+ changesets.order("created_at DESC").limit(100).each do |cs|
+ results.root << cs.to_xml_node
+ end
+
+ render :text => results.to_s, :content_type => "text/xml"
+ end
+
+ ##
+ # updates a changeset's tags. none of the changeset's attributes are
+ # user-modifiable, so they will be ignored.
+ #
+ # changesets are not (yet?) versioned, so we don't have to deal with
+ # history tables here. changesets are locked to a single user, however.
+ #
+ # after succesful update, returns the XML of the changeset.
+ def update
+ # request *must* be a PUT.
+ assert_method :put
+
+ changeset = Changeset.find(params[:id])
+ new_changeset = Changeset.from_xml(request.raw_post)
+
+ unless new_changeset.nil?
+ check_changeset_consistency(changeset, @user)
+ changeset.update_from(new_changeset, @user)
+ render :text => changeset.to_xml, :mime_type => "text/xml"
+ else
+
+ render :nothing => true, :status => :bad_request
+ end
+ end
+
+ ##
+ # list edits (open changesets) in reverse chronological order
+ def list
+ if request.format == :atom and params[:page]
+ redirect_to params.merge({ :page => nil }), :status => :moved_permanently
+ else
+ changesets = conditions_nonempty(Changeset.scoped)
+
+ if params[:display_name]
+ user = User.find_by_display_name(params[:display_name])
+
+ if user and user.active?
+ if user.data_public? or user == @user
+ changesets = changesets.where(:user_id => user.id)
+ else
+ changesets = changesets.where("false")
+ end
+ else
+ render_unknown_user params[:display_name]
+ return
+ end
+ end
+
+ if params[:friends]
+ if @user
+ changesets = changesets.where(:user_id => @user.friend_users.public)
+ elsif request.format == :html
+ require_user
+ return
+ end