]> git.openstreetmap.org Git - rails.git/blobdiff - app/models/way.rb
Creating consistency check for creation of nodes, way and relations. Moving some...
[rails.git] / app / models / way.rb
index 05b412b299f888bfab09026bed4b89d0414c3cb4..b2bdfb39b0e0e96bc6ee4d497b240ade8238eef2 100644 (file)
@@ -1,5 +1,7 @@
 class Way < ActiveRecord::Base
   require 'xml/libxml'
 class Way < ActiveRecord::Base
   require 'xml/libxml'
+  
+  include ConsistencyValidations
 
   set_table_name 'current_ways'
 
 
   set_table_name 'current_ways'
 
@@ -217,6 +219,16 @@ class Way < ActiveRecord::Base
     save_with_history!
   end
 
     save_with_history!
   end
 
+  def create_with_history(user)
+    check_create_consistency(self, user)
+    if !self.preconditions_ok?
+      raise OSM::APIPreconditionsFailedError.new
+    end
+    self.version = 0
+    self.visible = true
+    save_with_history!
+  end
+
   def preconditions_ok?
     return false if self.nds.empty?
     self.nds.each do |n|
   def preconditions_ok?
     return false if self.nds.empty?
     self.nds.each do |n|