X-Git-Url: https://git.openstreetmap.org/rails.git/blobdiff_plain/40414cf324309d13d207f9339b7f40ce05a9fa2a..2c16177174d276335babcca5439cd4e97af62ffa:/app/models/changeset.rb diff --git a/app/models/changeset.rb b/app/models/changeset.rb index 04023ae2b..dc6c0e014 100644 --- a/app/models/changeset.rb +++ b/app/models/changeset.rb @@ -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 + 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 @@ -37,6 +47,10 @@ class Changeset < ActiveRecord::Base return cs end + def tags_as_hash + return tags + end + def tags unless @tags @tags = {} @@ -61,6 +75,7 @@ class Changeset < ActiveRecord::Base Changeset.transaction do # fixme update modified_at time? + # FIXME there is no modified_at time, should it be added self.save! end @@ -83,6 +98,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