X-Git-Url: https://git.openstreetmap.org./rails.git/blobdiff_plain/12c1d5e6c05813a0697724277b4d8529a1a7c240..e15a92a30213d87e10e000a240a7dcab66c208b4:/app/models/relation.rb?ds=sidebyside diff --git a/app/models/relation.rb b/app/models/relation.rb index 0a4a660a6..69e2acfd1 100644 --- a/app/models/relation.rb +++ b/app/models/relation.rb @@ -166,7 +166,7 @@ class Relation < ApplicationRecord # shouldn't be possible to get race conditions. Relation.transaction do lock! - check_consistency(self, new_relation, user) + check_update_element_consistency(self, new_relation, user) # This will check to see if this relation is used by another relation rel = RelationMember.joins(:relation).find_by("visible = ? AND member_type = 'Relation' and member_id = ? ", true, id) raise OSM::APIPreconditionFailedError, "The relation #{new_relation.id} is used in relation #{rel.relation.id}." unless rel.nil? @@ -182,7 +182,7 @@ class Relation < ApplicationRecord def update_from(new_relation, user) Relation.transaction do lock! - check_consistency(self, new_relation, user) + check_update_element_consistency(self, new_relation, user) raise OSM::APIPreconditionFailedError, "Cannot update relation #{id}: data or member data is invalid." unless new_relation.preconditions_ok?(members) self.changeset_id = new_relation.changeset_id @@ -195,7 +195,7 @@ class Relation < ApplicationRecord end def create_with_history(user) - check_create_consistency(self, user) + check_create_element_consistency(self, user) raise OSM::APIPreconditionFailedError, "Cannot create relation: data or member data is invalid." unless preconditions_ok? self.version = 0 @@ -234,7 +234,7 @@ class Relation < ApplicationRecord element = model.lock("for share").find_by(:id => m[1]) # and check that it is OK to use. - raise OSM::APIPreconditionFailedError, "Relation with id #{id} cannot be saved due to #{m[0]} with id #{m[1]}" unless element&.visible? && element&.preconditions_ok? + raise OSM::APIPreconditionFailedError, "Relation with id #{id} cannot be saved due to #{m[0]} with id #{m[1]}" unless element&.visible? && element.preconditions_ok? hash[m[1]] = true end