mirror of
https://github.com/meineerde/redmine.git
synced 2025-12-19 15:01:14 +00:00
Allow filtering of Redmine Reminders by Version (#18983).
Patch by Merul Patel. git-svn-id: http://svn.redmine.org/redmine/trunk@13964 e93f8b46-1217-0410-a6f0-8f06a7374b81
This commit is contained in:
parent
bce16a471c
commit
e94920a5ff
@ -319,10 +319,12 @@ class Mailer < ActionMailer::Base
|
|||||||
# * :tracker => id of tracker for filtering issues (defaults to all trackers)
|
# * :tracker => id of tracker for filtering issues (defaults to all trackers)
|
||||||
# * :project => id or identifier of project to process (defaults to all projects)
|
# * :project => id or identifier of project to process (defaults to all projects)
|
||||||
# * :users => array of user/group ids who should be reminded
|
# * :users => array of user/group ids who should be reminded
|
||||||
|
# * :version => name of target version for filtering issues (defaults to none)
|
||||||
def self.reminders(options={})
|
def self.reminders(options={})
|
||||||
days = options[:days] || 7
|
days = options[:days] || 7
|
||||||
project = options[:project] ? Project.find(options[:project]) : nil
|
project = options[:project] ? Project.find(options[:project]) : nil
|
||||||
tracker = options[:tracker] ? Tracker.find(options[:tracker]) : nil
|
tracker = options[:tracker] ? Tracker.find(options[:tracker]) : nil
|
||||||
|
target_versions = options[:version] ? Version.where(name: options[:version]).select(:id).map(&:id) : nil
|
||||||
user_ids = options[:users]
|
user_ids = options[:users]
|
||||||
|
|
||||||
scope = Issue.open.where("#{Issue.table_name}.assigned_to_id IS NOT NULL" +
|
scope = Issue.open.where("#{Issue.table_name}.assigned_to_id IS NOT NULL" +
|
||||||
@ -331,6 +333,7 @@ class Mailer < ActionMailer::Base
|
|||||||
)
|
)
|
||||||
scope = scope.where(:assigned_to_id => user_ids) if user_ids.present?
|
scope = scope.where(:assigned_to_id => user_ids) if user_ids.present?
|
||||||
scope = scope.where(:project_id => project.id) if project
|
scope = scope.where(:project_id => project.id) if project
|
||||||
|
scope = scope.where(:fixed_version_id => target_versions) unless target_versions.blank?
|
||||||
scope = scope.where(:tracker_id => tracker.id) if tracker
|
scope = scope.where(:tracker_id => tracker.id) if tracker
|
||||||
issues_by_assignee = scope.includes(:status, :assigned_to, :project, :tracker).
|
issues_by_assignee = scope.includes(:status, :assigned_to, :project, :tracker).
|
||||||
group_by(&:assigned_to)
|
group_by(&:assigned_to)
|
||||||
|
|||||||
@ -23,6 +23,7 @@ Available options:
|
|||||||
* tracker => id of tracker (defaults to all trackers)
|
* tracker => id of tracker (defaults to all trackers)
|
||||||
* project => id or identifier of project (defaults to all projects)
|
* project => id or identifier of project (defaults to all projects)
|
||||||
* users => comma separated list of user/group ids who should be reminded
|
* users => comma separated list of user/group ids who should be reminded
|
||||||
|
* version => name of target version for filtering issues (defaults to none)
|
||||||
|
|
||||||
Example:
|
Example:
|
||||||
rake redmine:send_reminders days=7 users="1,23, 56" RAILS_ENV="production"
|
rake redmine:send_reminders days=7 users="1,23, 56" RAILS_ENV="production"
|
||||||
@ -35,6 +36,7 @@ namespace :redmine do
|
|||||||
options[:project] = ENV['project'] if ENV['project']
|
options[:project] = ENV['project'] if ENV['project']
|
||||||
options[:tracker] = ENV['tracker'].to_i if ENV['tracker']
|
options[:tracker] = ENV['tracker'].to_i if ENV['tracker']
|
||||||
options[:users] = (ENV['users'] || '').split(',').each(&:strip!)
|
options[:users] = (ENV['users'] || '').split(',').each(&:strip!)
|
||||||
|
options[:version] = ENV['version'] if ENV['version']
|
||||||
|
|
||||||
Mailer.with_synched_deliveries do
|
Mailer.with_synched_deliveries do
|
||||||
Mailer.reminders(options)
|
Mailer.reminders(options)
|
||||||
|
|||||||
@ -633,6 +633,27 @@ class MailerTest < ActiveSupport::TestCase
|
|||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
|
def test_reminders_for_versions
|
||||||
|
with_settings :default_language => 'en' do
|
||||||
|
Mailer.reminders(:days => 42, :users => ['3'])
|
||||||
|
assert_equal 1, ActionMailer::Base.deliveries.size
|
||||||
|
|
||||||
|
ActionMailer::Base.deliveries.clear
|
||||||
|
Version.create!(name: 'Acme', project_id: 1, sharing: 'none')
|
||||||
|
Mailer.reminders(:days => 42, :users => ['3'], :version => 'Acme')
|
||||||
|
assert_equal 0, ActionMailer::Base.deliveries.size
|
||||||
|
Issue.create!(:project_id => 1, :tracker_id => 1, :status_id => 1,
|
||||||
|
:subject => 'Assigned to user', :assigned_to => User.find(3),
|
||||||
|
:due_date => 5.days.from_now,
|
||||||
|
:author_id => 2)
|
||||||
|
Mailer.reminders(:days => 42, :users => ['3'], :version => 'Acme')
|
||||||
|
assert_equal 1, ActionMailer::Base.deliveries.size
|
||||||
|
|
||||||
|
mail = last_email
|
||||||
|
assert mail.bcc.include?('dlopper@somenet.foo')
|
||||||
|
end
|
||||||
|
end
|
||||||
|
|
||||||
def test_mailer_should_not_change_locale
|
def test_mailer_should_not_change_locale
|
||||||
# Set current language to italian
|
# Set current language to italian
|
||||||
set_language_if_valid 'it'
|
set_language_if_valid 'it'
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user