]> git.openstreetmap.org Git - rails.git/blobdiff - app/models/changeset.rb
some useful notes in code for ideas that require implementing.
[rails.git] / app / models / changeset.rb
index 983f7544c11710ce330c2958f192915732142352..7e2216f0e501165c6e2f1b2b870f52eb70e6b991 100644 (file)
@@ -4,6 +4,22 @@ class Changeset < ActiveRecord::Base
   belongs_to :user
 
   has_many :changeset_tags, :foreign_key => 'id'
+  
+  has_many :nodes
+  has_many :ways
+  has_many :relations
+  has_many :old_nodes
+  has_many :old_ways
+  has_many :old_relations
+  
+  validates_presence_of :user_id, :created_at, :open
+  
+  # Use a method like this, so that we can easily change how we
+  # determine whether a changeset is open, without breaking code in at 
+  # least 6 controllers
+  def is_open?
+    return open
+  end
 
   def self.from_xml(xml, create=false)
     begin
@@ -76,6 +92,7 @@ class Changeset < ActiveRecord::Base
     doc.root << to_xml_node()
     return doc
   end
+  
   def to_xml_node(user_display_name_cache = nil)
     el1 = XML::Node.new 'changeset'
     el1['id'] = self.id.to_s
@@ -100,6 +117,11 @@ class Changeset < ActiveRecord::Base
     end
     
     el1['created_at'] = self.created_at.xmlschema
+    el1['open'] = self.open.to_s
+
+    # FIXME FIXME FIXME: This does not include changes yet! There is 
+    # currently no changeset_id column in the tables as far as I can tell,
+    # so this is just a scaffold to build on, not a complete to_xml
 
     return el1
   end