summaryrefslogtreecommitdiffstats
path: root/app/models
diff options
context:
space:
mode:
authorJean-Philippe Lang <jp_lang@yahoo.fr>2008-05-25 17:31:50 +0000
committerJean-Philippe Lang <jp_lang@yahoo.fr>2008-05-25 17:31:50 +0000
commit0c8105277070c20590d22a0d4b8fc1f09ce981d9 (patch)
treecc03ec6f7da3f6b6b1ebd8c4a73f36276050b1a8 /app/models
parentd99dc4070a925fabc050ae61c21c64548730a636 (diff)
downloadredmine-0c8105277070c20590d22a0d4b8fc1f09ce981d9.tar.gz
redmine-0c8105277070c20590d22a0d4b8fc1f09ce981d9.zip
Adds a rake task to send reminders. An email is sent to each user with a list of the issues due in the next days, if any.
See @rake -D redmine:send_reminders@ for options. git-svn-id: http://redmine.rubyforge.org/svn/trunk@1459 e93f8b46-1217-0410-a6f0-8f06a7374b81
Diffstat (limited to 'app/models')
-rw-r--r--app/models/mailer.rb31
1 files changed, 31 insertions, 0 deletions
diff --git a/app/models/mailer.rb b/app/models/mailer.rb
index 6fc879a15..aae374268 100644
--- a/app/models/mailer.rb
+++ b/app/models/mailer.rb
@@ -51,6 +51,15 @@ class Mailer < ActionMailer::Base
:issue_url => url_for(:controller => 'issues', :action => 'show', :id => issue)
end
+ def reminder(user, issues, days)
+ set_language_if_valid user.language
+ recipients user.mail
+ subject l(:mail_subject_reminder, issues.size)
+ body :issues => issues,
+ :days => days,
+ :issues_url => url_for(:controller => 'issues', :action => 'index', :set_filter => 1, :assigned_to_id => user.id, :sort_key => 'issues.due_date', :sort_order => 'asc')
+ end
+
def document_added(document)
redmine_headers 'Project' => document.project.identifier
recipients document.project.recipients
@@ -144,6 +153,28 @@ class Mailer < ActionMailer::Base
(bcc.nil? || bcc.empty?)
super
end
+
+ # Sends reminders to issue assignees
+ # Available options:
+ # * :days => how many days in the future to remind about (defaults to 7)
+ # * :tracker => id of tracker for filtering issues (defaults to all trackers)
+ # * :project => id or identifier of project to process (defaults to all projects)
+ def self.reminders(options={})
+ days = options[:days] || 7
+ project = options[:project] ? Project.find(options[:project]) : nil
+ tracker = options[:tracker] ? Tracker.find(options[:tracker]) : nil
+
+ s = ARCondition.new ["#{IssueStatus.table_name}.is_closed = ? AND #{Issue.table_name}.due_date <= ? AND #{Issue.table_name}.assigned_to_id IS NOT NULL", false, days.day.from_now.to_date]
+ s << "#{Issue.table_name}.project_id = #{project.id}" if project
+ s << "#{Issue.table_name}.tracker_id = #{tracker.id}" if tracker
+
+ issues_by_assignee = Issue.find(:all, :include => [:status, :assigned_to, :project, :tracker],
+ :conditions => s.conditions
+ ).group_by(&:assigned_to)
+ issues_by_assignee.each do |assignee, issues|
+ deliver_reminder(assignee, issues, days) unless assignee.nil?
+ end
+ end
private
def initialize_defaults(method_name)