Creating consistency check for creation of nodes, way and relations. Moving some creation code from the controller to the model, and adding error handling on create errors.

This commit is contained in:
Shaun McDonald 2008-10-13 15:39:21 +00:00
parent 127bb4523e
commit fb5f39f19a
7 changed files with 70 additions and 44 deletions

View file

@ -16,4 +16,15 @@ module ConsistencyValidations
raise OSM::APIChangesetAlreadyClosedError.new
end
end
# This is similar to above, just some validations don't apply
def check_create_consistency(new, user)
if new.changeset.nil?
raise OSM::APIChangesetMissingError.new
elsif new.changeset.user_id != user.id
raise OSM::APIUserChangesetMismatchError.new
elsif not new.changeset.is_open?
raise OSM::APIChangesetAlreadyClosedError.new
end
end
end