precondition stuff

This commit is contained in:
Steve Coast 2006-12-13 16:05:37 +00:00
parent 374d9ea486
commit 9189093997
4 changed files with 27 additions and 6 deletions

View file

@ -13,11 +13,11 @@ class SegmentController < ApplicationController
segment.user_id = @user.id
a = Node.find(segment.node_a.to_i)
b = Node.find(segment.node_b.to_i)
segment.from_node = Node.find(segment.node_a.to_i)
segment.to_node = Node.find(segment.node_b.to_i)
unless a and a.visible and b and b.visible
render :nothing => true, :status => 400
unless segment.precondtions_ok? # are the nodes visible?
render :nothing => true, :status => 412
end
if segment.save_with_history

View file

@ -10,10 +10,17 @@ class WayController < ApplicationController
if way
way.user_id = @user.id
unless way.precondtions_ok? # are the segments (and their nodes) visible?
render :nothing => true, :status => 412
return
end
if way.save_with_history
render :text => way.id
return
else
render :nothing => true, :status => 500
return
end
return
else
@ -33,7 +40,7 @@ class WayController < ApplicationController
way = Way.find(params[:id])
case request.method
when :get
unless way.visible
render :nothing => true, :status => 410