Skip to content

Commit

Permalink
Refactor: Move recipients method into acts_as_event
Browse files Browse the repository at this point in the history
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
  • Loading branch information
edavis10 committed Feb 1, 2010
1 parent d43c860 commit 358e319
Show file tree
Hide file tree
Showing 4 changed files with 7 additions and 21 deletions.
7 changes: 0 additions & 7 deletions app/models/document.rb
Expand Up @@ -46,11 +46,4 @@ def updated_on
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
7 changes: 0 additions & 7 deletions app/models/message.rb
Expand Up @@ -90,13 +90,6 @@ def destroyable_by?(usr)
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
Expand Down
7 changes: 0 additions & 7 deletions app/models/news.rb
Expand Up @@ -33,13 +33,6 @@ def visible?(user=User.current)
!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")
Expand Down
7 changes: 7 additions & 0 deletions vendor/plugins/acts_as_event/lib/acts_as_event.rb
Expand Up @@ -68,6 +68,13 @@ def event_url(options = {})
(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
Expand Down

0 comments on commit 358e319

Please sign in to comment.