]> git.openstreetmap.org Git - rails.git/blob - app/models/redaction.rb
Add frozen_string_literal comments to ruby files
[rails.git] / app / models / redaction.rb
1 # frozen_string_literal: true
2
3 # == Schema Information
4 #
5 # Table name: redactions
6 #
7 #  id                 :integer          not null, primary key
8 #  title              :string           not null
9 #  description        :text             not null
10 #  created_at         :datetime
11 #  updated_at         :datetime
12 #  user_id            :bigint           not null
13 #  description_format :enum             default("markdown"), not null
14 #
15 # Foreign Keys
16 #
17 #  redactions_user_id_fkey  (user_id => users.id)
18 #
19
20 ##
21 # Redaction represents a record associated with a particular
22 # action on the database to hide revisions from the history
23 # which are not appropriate to redistribute any more.
24 #
25 # The circumstances of the redaction can be recorded in the
26 # record's title and description fields, which can be
27 # displayed linked from the redacted records.
28 #
29 class Redaction < ApplicationRecord
30   belongs_to :user
31
32   has_many :old_nodes
33   has_many :old_ways
34   has_many :old_relations
35
36   validates :title, :presence => true, :characters => true
37   validates :description, :presence => true, :characters => true
38   validates :description_format, :inclusion => { :in => %w[text html markdown] }
39
40   # this method overrides the AR default to provide the rich
41   # text object for the description field.
42   def description
43     RichText.new(self[:description_format], self[:description])
44   end
45 end