From 358e3194d79b9e4503edd48d2179b9f8f2920cd3 Mon Sep 17 00:00:00 2001 From: Eric Davis Date: Mon, 1 Feb 2010 18:57:12 +0000 Subject: [PATCH] Refactor: Move recipients method into acts_as_event acts_as_event should be the standard interface to Redmine events, like mail notifications, so having a standard recipients implementation there makes sense. git-svn-id: svn+ssh://rubyforge.org/var/svn/redmine/trunk@3358 e93f8b46-1217-0410-a6f0-8f06a7374b81 --- app/models/document.rb | 7 ------- app/models/message.rb | 7 ------- app/models/news.rb | 7 ------- vendor/plugins/acts_as_event/lib/acts_as_event.rb | 7 +++++++ 4 files changed, 7 insertions(+), 21 deletions(-) diff --git a/app/models/document.rb b/app/models/document.rb index d2d20d05d..3aae39850 100644 --- a/app/models/document.rb +++ b/app/models/document.rb @@ -46,11 +46,4 @@ class Document < ActiveRecord::Base end @updated_on end - - # Returns the mail adresses of users that should be notified - def recipients - notified = project.notified_users - notified.reject! {|user| !visible?(user)} - notified.collect(&:mail) - end end diff --git a/app/models/message.rb b/app/models/message.rb index 535143775..1e59719dd 100644 --- a/app/models/message.rb +++ b/app/models/message.rb @@ -90,13 +90,6 @@ class Message < ActiveRecord::Base usr && usr.logged? && (usr.allowed_to?(:delete_messages, project) || (self.author == usr && usr.allowed_to?(:delete_own_messages, project))) end - # Returns the mail adresses of users that should be notified - def recipients - notified = project.notified_users - notified.reject! {|user| !visible?(user)} - notified.collect(&:mail) - end - private def add_author_as_watcher diff --git a/app/models/news.rb b/app/models/news.rb index a7b173439..a167cdf38 100644 --- a/app/models/news.rb +++ b/app/models/news.rb @@ -33,13 +33,6 @@ class News < ActiveRecord::Base !user.nil? && user.allowed_to?(:view_news, project) end - # Returns the mail adresses of users that should be notified - def recipients - notified = project.notified_users - notified.reject! {|user| !visible?(user)} - notified.collect(&:mail) - end - # returns latest news for projects visible by user 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") diff --git a/vendor/plugins/acts_as_event/lib/acts_as_event.rb b/vendor/plugins/acts_as_event/lib/acts_as_event.rb index 0b7ad21f5..1aa7ddf01 100644 --- a/vendor/plugins/acts_as_event/lib/acts_as_event.rb +++ b/vendor/plugins/acts_as_event/lib/acts_as_event.rb @@ -68,6 +68,13 @@ module Redmine (option.is_a?(Proc) ? option.call(self) : send(option)).merge(options) end + # Returns the mail adresses of users that should be notified + def recipients + notified = project.notified_users + notified.reject! {|user| !visible?(user)} + notified.collect(&:mail) + end + module ClassMethods end end