api06: Fix diff uploading (still doesn't give a useful response):

Modification and deletion works fine now.  Rollback also works apparently.
Just auto increment doesn't get reset.
This commit is contained in:
Gabriel Ebner 2008-05-04 15:16:58 +00:00
parent e7e5ae7aaa
commit 6ebb7045fe
7 changed files with 98 additions and 116 deletions

View file

@ -51,35 +51,18 @@ class WayController < ApplicationController
new_way = Way.from_xml(request.raw_post)
if new_way and new_way.id == way.id
unless update_internal(way, new_way)
render :text => "", :status => :precondition_failed
else
render :nothing => true
end
way.update_from(new_way, @user)
render :nothing => true
else
render :nothing => true, :status => :bad_request
end
rescue OSM::APIPreconditionFailedError
render :text => "", :status => :precondition_failed
rescue ActiveRecord::RecordNotFound
render :nothing => true, :status => :not_found
end
end
def update_internal way, new_way
way = Way.find(new_way.id) if way.nil?
if !new_way.preconditions_ok?
return false
else
way.user_id = @user.id
way.tags = new_way.tags
way.nds = new_way.nds
way.visible = true
way.save_with_history!
return true
end
end
# This is the API call to delete a way
def delete
begin