]> git.openstreetmap.org Git - rails.git/blobdiff - app/models/changeset.rb
Fix the data config, so that the development database is not the same as the test...
[rails.git] / app / models / changeset.rb
index 04023ae2b94a6f883966b4aead228ac57508d439..934d75e39de953d51e9bd98221e4b1815056be81 100644 (file)
@@ -11,6 +11,16 @@ class Changeset < ActiveRecord::Base
   has_many :old_nodes
   has_many :old_ways
   has_many :old_relations
+  
+  validates_presence_of :user_id, :created_at, :open
+  validates_inclusion_of :open, :in => [ true, false ]
+  
+  # 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
@@ -83,6 +93,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