1 # frozen_string_literal: true
 
   3 # == Schema Information
 
   5 # Table name: redactions
 
   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
 
  17 #  redactions_user_id_fkey  (user_id => users.id)
 
  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.
 
  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.
 
  29 class Redaction < ApplicationRecord
 
  34   has_many :old_relations
 
  36   validates :title, :presence => true, :characters => true
 
  37   validates :description, :presence => true, :characters => true
 
  38   validates :description_format, :inclusion => { :in => %w[text html markdown] }
 
  40   # this method overrides the AR default to provide the rich
 
  41   # text object for the description field.
 
  43     RichText.new(self[:description_format], self[:description])