]> git.openstreetmap.org Git - rails.git/blobdiff - app/models/relation.rb
adding changeset stuff for the data browser
[rails.git] / app / models / relation.rb
index dd2d1c7d5f1e4f18e6ae10703e780e8825b0bb69..436c1e32ef8693bf068429743000b38cfe8f4546 100644 (file)
@@ -182,6 +182,11 @@ class Relation < ActiveRecord::Base
 
   def add_tag_keyval(k, v)
     @tags = Hash.new unless @tags
+
+    # duplicate tags are now forbidden, so we can't allow values
+    # in the hash to be overwritten.
+    raise OSM::APIDuplicateTagsError.new if @tags.include? k
+
     @tags[k] = v
   end
 
@@ -251,6 +256,16 @@ class Relation < ActiveRecord::Base
     self.visible = true
     save_with_history!
   end
+  
+  def create_with_history(user)
+    check_create_consistency(self, user)
+    if !self.preconditions_ok?
+      raise OSM::APIPreconditionFailedError.new
+    end
+    self.version = 0
+    self.visible = true
+    save_with_history!
+  end
 
   def preconditions_ok?
     # These are hastables that store an id in the index of all