1 # == Schema Information
 
   5 #  id         :integer          not null, primary key
 
   6 #  issue_id   :integer          not null
 
   7 #  user_id    :integer          not null
 
   8 #  details    :text             not null
 
   9 #  category   :string           not null
 
  10 #  created_at :datetime         not null
 
  11 #  updated_at :datetime         not null
 
  15 #  index_reports_on_issue_id  (issue_id)
 
  16 #  index_reports_on_user_id   (user_id)
 
  20 #  reports_issue_id_fkey  (issue_id => issues.id)
 
  21 #  reports_user_id_fkey   (user_id => users.id)
 
  24 class Report < ApplicationRecord
 
  25   belongs_to :issue, :counter_cache => true
 
  28   validates :details, :presence => true, :characters => true
 
  29   validates :category, :presence => true
 
  31   def self.categories_for(reportable)
 
  32     case reportable.class.name
 
  33     when "DiaryEntry", "DiaryComment" then %w[spam offensive threat other]
 
  34     when "User" then %w[spam offensive threat vandal other]
 
  35     when "Note" then %w[spam personal abusive other]
 
  41     RichText.new("markdown", self[:details])