suggest_article.rb
1.68 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
class SuggestArticle < Task
  validates_presence_of :target_id, :article_name, :email, :name, :article_body
  settings_items :email, :type => String
  settings_items :name, :type => String
  settings_items :article_name, :type => String
  settings_items :article_body, :type => String
  settings_items :article_abstract, :type => String
  settings_items :article_parent_id, :type => String
  settings_items :source, :type => String
  settings_items :source_name, :type => String
  settings_items :highlighted, :type => :boolean, :default => false
  def sender
    "#{name} (#{email})"
  end
  def perform
    TinyMceArticle.create!(
      :profile => target,
      :name => article_name,
      :author_name => name,
      :body => article_body,
      :abstract => article_abstract,
      :parent_id => article_parent_id,
      :source => source,
      :source_name => source_name,
      :highlighted => highlighted
    )
  end
  def title
    _("Article suggestion")
  end
  def subject
    article_name
  end
  def information
    { :message => _('%{sender} suggested the publication of the article: %{subject}.'),
      :variables => {:sender => sender} }
  end
  def accept_details
    true
  end
  def icon
    result = {:type => :defined_image, :src => '/images/icons-app/article-minor.png', :name => article_name}
  end
  def target_notification_description
    _('%{sender} suggested the publication of the article: %{article}.') %
    {:sender => sender, :article => article_name}
  end
  def target_notification_message
    target_notification_description + "\n\n" +
    _('You need to login on %{system} in order to approve or reject this article.') % { :system => target.environment.name }
  end
end