- if WaySegment.find(:first, :joins => "INNER JOIN current_ways ON current_ways.id = current_way_segments.id", :conditions => [ "current_ways.visible = 1 AND current_way_segments.segment_id = ?", segment.id ])
- render :nothing => true, :status => HTTP_PRECONDITION_FAILED
+ new_segment = Segment.from_xml(request.raw_post)
+
+ if new_segment and new_segment.id == segment.id
+ if new_segment.node_a == new_segment.node_b
+ render :nothing => true, :status => :expectation_failed
+ elsif !new_segment.preconditions_ok?
+ render :nothing => true, :status => :precondition_failed
+ else
+ segment.user_id = @user.id
+ segment.node_a = new_segment.node_a
+ segment.node_b = new_segment.node_b
+ segment.tags = new_segment.tags
+ segment.visible = new_segment.visible
+
+ if segment.save_with_history
+ render :nothing => true
+ else
+ render :nothing => true, :status => :internal_server_error
+ end
+ end