diff options
author | Jean-Philippe Lang <jp_lang@yahoo.fr> | 2011-07-20 17:05:17 +0000 |
---|---|---|
committer | Jean-Philippe Lang <jp_lang@yahoo.fr> | 2011-07-20 17:05:17 +0000 |
commit | 5f79a6a19069a538d12509ae66f8811c6bba69fb (patch) | |
tree | 9dde9fcc482e02c33030cb421d53448c98037e97 /app/models/issue_status.rb | |
parent | cf56698d91cedb461726200cf0e32834e7124cda (diff) | |
download | redmine-5f79a6a19069a538d12509ae66f8811c6bba69fb.tar.gz redmine-5f79a6a19069a538d12509ae66f8811c6bba69fb.zip |
Fixed: additional workflow transitions not available when set to both author and assignee (#8836).
git-svn-id: svn+ssh://rubyforge.org/var/svn/redmine/trunk@6300 e93f8b46-1217-0410-a6f0-8f06a7374b81
Diffstat (limited to 'app/models/issue_status.rb')
-rw-r--r-- | app/models/issue_status.rb | 18 |
1 files changed, 10 insertions, 8 deletions
diff --git a/app/models/issue_status.rb b/app/models/issue_status.rb index f2db4b570..e0860be84 100644 --- a/app/models/issue_status.rb +++ b/app/models/issue_status.rb @@ -58,8 +58,7 @@ class IssueStatus < ActiveRecord::Base transitions = workflows.select do |w| role_ids.include?(w.role_id) && w.tracker_id == tracker.id && - (author || !w.author) && - (assignee || !w.assignee) + ((!w.author && !w.assignee) || (author && w.author) || (assignee && w.assignee)) end transitions.collect{|w| w.new_status}.compact.sort else @@ -70,14 +69,17 @@ class IssueStatus < ActiveRecord::Base # Same thing as above but uses a database query # More efficient than the previous method if called just once def find_new_statuses_allowed_to(roles, tracker, author=false, assignee=false) - if roles && tracker - conditions = {:role_id => roles.collect(&:id), :tracker_id => tracker.id} - conditions[:author] = false unless author - conditions[:assignee] = false unless assignee + if roles.present? && tracker + conditions = "(author = :false AND assignee = :false)" + conditions << " OR author = :true" if author + conditions << " OR assignee = :true" if assignee workflows.find(:all, - :include => :new_status, - :conditions => conditions).collect{|w| w.new_status}.compact.sort + :include => :new_status, + :conditions => ["role_id IN (:role_ids) AND tracker_id = :tracker_id AND (#{conditions})", + {:role_ids => roles.collect(&:id), :tracker_id => tracker.id, :true => true, :false => false} + ] + ).collect{|w| w.new_status}.compact.sort else [] end |