diff options
author | Jean-Philippe Lang <jp_lang@yahoo.fr> | 2011-03-04 14:32:58 +0000 |
---|---|---|
committer | Jean-Philippe Lang <jp_lang@yahoo.fr> | 2011-03-04 14:32:58 +0000 |
commit | 36009de154e0d7c50d56f21e79e0f812d9d8b5e8 (patch) | |
tree | 94534f093b942f97c90e004350b95fe1a6a0afd0 /app/models/news.rb | |
parent | 8d3773e0e1d0e259a2a193f31515ee910eb88626 (diff) | |
download | redmine-36009de154e0d7c50d56f21e79e0f812d9d8b5e8.tar.gz redmine-36009de154e0d7c50d56f21e79e0f812d9d8b5e8.zip |
Adds email notifications support for news comments (#2074).
git-svn-id: svn+ssh://rubyforge.org/var/svn/redmine/trunk@5003 e93f8b46-1217-0410-a6f0-8f06a7374b81
Diffstat (limited to 'app/models/news.rb')
-rw-r--r-- | app/models/news.rb | 11 |
1 files changed, 10 insertions, 1 deletions
diff --git a/app/models/news.rb b/app/models/news.rb index 00729f06c..7f8c73107 100644 --- a/app/models/news.rb +++ b/app/models/news.rb @@ -1,5 +1,5 @@ # Redmine - project management software -# Copyright (C) 2006-2008 Jean-Philippe Lang +# Copyright (C) 2006-2011 Jean-Philippe Lang # # This program is free software; you can redistribute it and/or # modify it under the terms of the GNU General Public License @@ -28,6 +28,9 @@ class News < ActiveRecord::Base acts_as_event :url => Proc.new {|o| {:controller => 'news', :action => 'show', :id => o.id}} acts_as_activity_provider :find_options => {:include => [:project, :author]}, :author_key => :author_id + acts_as_watchable + + after_create :add_author_as_watcher named_scope :visible, lambda {|*args| { :include => :project, @@ -42,4 +45,10 @@ class News < ActiveRecord::Base def self.latest(user = User.current, count = 5) find(:all, :limit => count, :conditions => Project.allowed_to_condition(user, :view_news), :include => [ :author, :project ], :order => "#{News.table_name}.created_on DESC") end + + private + + def add_author_as_watcher + Watcher.create(:watchable => self, :user => author) + end end |