]> git.openstreetmap.org Git - rails.git/blob - app/models/redaction.rb
Merge branch 'master' into notes
[rails.git] / app / models / redaction.rb
1 ##
2 # Redaction represents a record associated with a particular
3 # action on the database to hide revisions from the history
4 # which are not appropriate to redistribute any more. 
5 #
6 # The circumstances of the redaction can be recorded in the
7 # record's title and description fields, which can be 
8 # displayed linked from the redacted records.
9 #
10 class Redaction < ActiveRecord::Base
11   belongs_to :user
12
13   has_many :old_nodes
14   has_many :old_ways
15   has_many :old_relations
16
17   after_initialize :set_defaults
18
19   # this method overrides the AR default to provide the rich 
20   # text object for the description field.
21   def description
22     RichText.new(read_attribute(:description_format), read_attribute(:description))
23   end
24
25   private
26
27   # set the default format to be markdown, in the absence of
28   # any other setting.
29   def set_defaults
30     self.description_format = "markdown" unless self.attribute_present?(:description_format)
31   end
32 end