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 < ActiveRecord::Base
25 belongs_to :issue, :counter_cache => true
28 validates :issue, :presence => true
29 validates :user, :presence => true
30 validates :details, :presence => true, :characters => true
31 validates :category, :presence => true
33 def self.categories_for(reportable)
34 case reportable.class.name
35 when "DiaryEntry" then %w[spam offensive threat other]
36 when "DiaryComment" then %w[spam offensive threat other]
37 when "User" then %w[spam offensive threat vandal other]
38 when "Note" then %w[spam personal abusive other]