summaryrefslogtreecommitdiffstats
path: root/app/models/issue_status.rb
diff options
context:
space:
mode:
authorJean-Philippe Lang <jp_lang@yahoo.fr>2011-02-20 15:38:07 +0000
committerJean-Philippe Lang <jp_lang@yahoo.fr>2011-02-20 15:38:07 +0000
commit4b096e9a56768dd5ba15304a903939f4e5e62e22 (patch)
tree032fb0361f6834929b0509a575ec1abcd7ba9da8 /app/models/issue_status.rb
parent7ddb1c694aaee2c36b0e3e67043f626903e0c961 (diff)
downloadredmine-4b096e9a56768dd5ba15304a903939f4e5e62e22.tar.gz
redmine-4b096e9a56768dd5ba15304a903939f4e5e62e22.zip
Allow additional workflow transitions for issue author and assignee (#2732).
git-svn-id: svn+ssh://rubyforge.org/var/svn/redmine/trunk@4895 e93f8b46-1217-0410-a6f0-8f06a7374b81
Diffstat (limited to 'app/models/issue_status.rb')
-rw-r--r--app/models/issue_status.rb27
1 files changed, 14 insertions, 13 deletions
diff --git a/app/models/issue_status.rb b/app/models/issue_status.rb
index 8171cdb79..5527e2c9a 100644
--- a/app/models/issue_status.rb
+++ b/app/models/issue_status.rb
@@ -50,10 +50,16 @@ class IssueStatus < ActiveRecord::Base
# Returns an array of all statuses the given role can switch to
# Uses association cache when called more than one time
- def new_statuses_allowed_to(roles, tracker)
+ def new_statuses_allowed_to(roles, tracker, author=false, assignee=false)
if roles && tracker
role_ids = roles.collect(&:id)
- new_statuses = workflows.select {|w| role_ids.include?(w.role_id) && w.tracker_id == tracker.id}.collect{|w| w.new_status}.compact.sort
+ transitions = workflows.select do |w|
+ role_ids.include?(w.role_id) &&
+ w.tracker_id == tracker.id &&
+ (author || !w.author) &&
+ (assignee || !w.assignee)
+ end
+ transitions.collect{|w| w.new_status}.compact.sort
else
[]
end
@@ -61,24 +67,19 @@ 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)
+ 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
+
workflows.find(:all,
:include => :new_status,
- :conditions => { :role_id => roles.collect(&:id),
- :tracker_id => tracker.id}).collect{ |w| w.new_status }.compact.sort
+ :conditions => conditions).collect{|w| w.new_status}.compact.sort
else
[]
end
end
-
- def new_status_allowed_to?(status, roles, tracker)
- if status && roles && tracker
- !workflows.find(:first, :conditions => {:new_status_id => status.id, :role_id => roles.collect(&:id), :tracker_id => tracker.id}).nil?
- else
- false
- end
- end
def <=>(status)
position <=> status.position