Blame view

app/models/abuse_complaint.rb 2.18 KB
3c89860d   Rodrigo Souto   Report abuse
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
class AbuseComplaint < Task
  has_many :abuse_reports, :dependent => :destroy
  belongs_to :reported, :class_name => "Profile", :foreign_key => "requestor_id"

  validates_presence_of :reported
  alias :requestor :reported

  def initialize(*args)
    super
    self.status = (args.first ? args.first[:status] : nil) || Task::Status::HIDDEN
  end

  after_update do |abuse_complaint|
    if abuse_complaint.reported.environment.reports_lower_bound < abuse_complaint.abuse_reports.count && abuse_complaint.status == Task::Status::HIDDEN
      abuse_complaint.activate
    end
  end

  def target
    reported.environment
  end

  def environment
    target
  end

  def title
f5e79695   Leandro Santos   fix wrong html pa...
28
    abuse_reports.count > 1 ? (_('Abuse complaint (%s)').html_safe % abuse_reports.count) :_('Abuse complaint')
3c89860d   Rodrigo Souto   Report abuse
29
30
31
32
33
34
35
36
37
38
39
40
41
42
  end

  def linked_subject
    {:text => reported.name, :url => reported.url}
  end

  def information
    {:message => _('%{linked_subject} was reported due to inappropriate behavior.')}
  end

  def accept_details
    true
  end

3c89860d   Rodrigo Souto   Report abuse
43
44
45
46
47
48
49
50
51
52
53
54
55
  def reject_details
    true
  end

  def icon
    {:type => :profile_image, :profile => reported, :url => reported.url}
  end

  def default_decision
    'skip'
  end

  def perform
f5e79695   Leandro Santos   fix wrong html pa...
56
    reported.disable
3c89860d   Rodrigo Souto   Report abuse
57
58
59
  end

  def task_activated_message
f5e79695   Leandro Santos   fix wrong html pa...
60
    _('Your profile was reported by the users of %s due to inappropriate behavior. The administrators of the environment are now reviewing the report. To solve this misunderstanding, please contact the administrators.').html_safe % environment.name
3c89860d   Rodrigo Souto   Report abuse
61
62
63
  end

  def task_finished_message
f5e79695   Leandro Santos   fix wrong html pa...
64
    _('Your profile was disabled by the administrators of %s due to inappropriate behavior. To solve this misunderstanding please contact them.').html_safe % environment.name
3c89860d   Rodrigo Souto   Report abuse
65
66
67
68
69
70
71
  end

  def target_notification_description
    _('%s was reported due to inappropriate behavior.').html_safe % reported.name
  end

  def target_notification_message