approve_article.rb
1.54 KB
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
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
class ApproveArticle < Task
serialize :data, Hash
validates_presence_of :requestor_id, :target_id
def description
_('%{author} wants to publish "%{article}" on %{community}') % { :author => requestor.name, :article => article_title, :community => target.name }
end
def article_title
article ? article.title : _('(The original text was removed)')
end
def data
self[:data] ||= {}
end
def article
Article.find_by_id data[:article_id]
end
def article= value
data[:article_id] = value.id
end
def name
data[:name]
end
def name= value
data[:name] = value
end
def closing_statment
data[:closing_statment]
end
def closing_statment= value
data[:closing_statment] = value
end
def article_parent_id= value
data[:parent_id] = value
end
def article_parent_id
data[:parent_id]
end
def article_parent
Article.find_by_id article_parent_id.to_i
end
def article_parent= value
self.article_parent_id = value.id
end
def highlighted= value
data[:highlighted] = value
end
def highlighted
data[:highlighted]
end
def perform
PublishedArticle.create!(:name => name, :profile => target, :reference_article => article, :parent => article_parent, :highlighted => highlighted)
end
def target_notification_message
return nil if target.organization? && !target.moderated_articles?
description + "\n\n" +
_('You need to login on %{system} in order to approve or reject this article.') % { :system => target.environment.name }
end
end