]> git.openstreetmap.org Git - rails.git/blobdiff - app/models/old_node.rb
Adding first cut of Redactions support
[rails.git] / app / models / old_node.rb
index 64ae1a70c9d8fe2050f2ccb3283bc04414dae030..5643a389bc8ad69fb83f7f886b122e97f4cbe8ff 100644 (file)
@@ -1,6 +1,7 @@
 class OldNode < ActiveRecord::Base
   include GeoRecord
   include ConsistencyValidations
+  include Redactable
 
   self.table_name = "nodes"
   self.primary_keys = "node_id", "version"
@@ -12,7 +13,9 @@ class OldNode < ActiveRecord::Base
   validates_associated :changeset
 
   belongs_to :changeset
+  belongs_to :redaction
+  belongs_to :current_node, :class_name => "Node", :foreign_key => "node_id"
+
   def validate_position
     errors.add(:base, "Node is not in the world") unless in_world?
   end
@@ -106,4 +109,10 @@ class OldNode < ActiveRecord::Base
   def containing_relation_members 
     return [] 
   end 
+
+  # check whether this element is the latest version - that is,
+  # has the same version as its "current" counterpart.
+  def is_latest_version?
+    current_node.version == self.version
+  end
 end