diff options
author | Jean-Philippe Lang <jp_lang@yahoo.fr> | 2008-05-25 17:31:50 +0000 |
---|---|---|
committer | Jean-Philippe Lang <jp_lang@yahoo.fr> | 2008-05-25 17:31:50 +0000 |
commit | 0c8105277070c20590d22a0d4b8fc1f09ce981d9 (patch) | |
tree | cc03ec6f7da3f6b6b1ebd8c4a73f36276050b1a8 /app | |
parent | d99dc4070a925fabc050ae61c21c64548730a636 (diff) | |
download | redmine-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')
-rw-r--r-- | app/models/mailer.rb | 31 | ||||
-rw-r--r-- | app/views/mailer/reminder.text.html.rhtml | 9 | ||||
-rw-r--r-- | app/views/mailer/reminder.text.plain.rhtml | 7 |
3 files changed, 47 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) diff --git a/app/views/mailer/reminder.text.html.rhtml b/app/views/mailer/reminder.text.html.rhtml new file mode 100644 index 000000000..1e33fbe43 --- /dev/null +++ b/app/views/mailer/reminder.text.html.rhtml @@ -0,0 +1,9 @@ +<p><%= l(:mail_body_reminder, @issues.size, @days) %></p> + +<ul> +<% @issues.each do |issue| -%> + <li><%=h "#{issue.project} - #{issue.tracker} ##{issue.id}: #{issue.subject}" %></li> +<% end -%> +</ul> + +<p><%= link_to l(:label_issue_view_all), @issues_url %></p> diff --git a/app/views/mailer/reminder.text.plain.rhtml b/app/views/mailer/reminder.text.plain.rhtml new file mode 100644 index 000000000..7e6a2e585 --- /dev/null +++ b/app/views/mailer/reminder.text.plain.rhtml @@ -0,0 +1,7 @@ +<%= l(:mail_body_reminder, @issues.size, @days) %>: + +<% @issues.each do |issue| -%> +* <%= "#{issue.project} - #{issue.tracker} ##{issue.id}: #{issue.subject}" %> +<% end -%> + +<%= @issues_url %> |