OSDN Git Service

Refactor: Move recipients method into acts_as_event
authorEric Davis <edavis@littlestreamsoftware.com>
Mon, 1 Feb 2010 18:57:12 +0000 (18:57 +0000)
committerEric Davis <edavis@littlestreamsoftware.com>
Mon, 1 Feb 2010 18:57:12 +0000 (18:57 +0000)
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
app/models/message.rb
app/models/news.rb
vendor/plugins/acts_as_event/lib/acts_as_event.rb

index d2d20d0..3aae398 100644 (file)
@@ -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
index 5351437..1e59719 100644 (file)
@@ -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
index a7b1734..a167cdf 100644 (file)
@@ -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")      
index 0b7ad21..1aa7ddf 100644 (file)
@@ -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