Mercurial > hg > soundsoftware-site
diff app/models/.svn/text-base/issue_status.rb.svn-base @ 245:051f544170fe
* Update to SVN trunk revision 4993
author | Chris Cannam |
---|---|
date | Thu, 03 Mar 2011 11:42:28 +0000 |
parents | 8661b858af72 |
children | 0c939c159af4 |
line wrap: on
line diff
--- a/app/models/.svn/text-base/issue_status.rb.svn-base Thu Mar 03 11:40:10 2011 +0000 +++ b/app/models/.svn/text-base/issue_status.rb.svn-base Thu Mar 03 11:42:28 2011 +0000 @@ -50,10 +50,16 @@ # 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 @@ # 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