@@ -38,16 +38,14 class IssueStatus < ActiveRecord::Base | |||||
38 | # Returns an array of all statuses the given role can switch to |
|
38 | # Returns an array of all statuses the given role can switch to | |
39 | # Uses association cache when called more than one time |
|
39 | # Uses association cache when called more than one time | |
40 | def new_statuses_allowed_to(role, tracker) |
|
40 | def new_statuses_allowed_to(role, tracker) | |
41 | new_statuses = [self] |
|
41 | new_statuses = workflows.select {|w| w.role_id == role.id && w.tracker_id == tracker.id}.collect{|w| w.new_status} if role && tracker | |
42 | new_statuses += workflows.select {|w| w.role_id == role.id && w.tracker_id == tracker.id}.collect{|w| w.new_status} if role && tracker |
|
|||
43 | new_statuses.sort{|x, y| x.position <=> y.position } |
|
42 | new_statuses.sort{|x, y| x.position <=> y.position } | |
44 | end |
|
43 | end | |
45 |
|
44 | |||
46 | # Same thing as above but uses a database query |
|
45 | # Same thing as above but uses a database query | |
47 | # More efficient than the previous method if called just once |
|
46 | # More efficient than the previous method if called just once | |
48 | def find_new_statuses_allowed_to(role, tracker) |
|
47 | def find_new_statuses_allowed_to(role, tracker) | |
49 |
new_statuses = |
|
48 | new_statuses = workflows.find(:all, | |
50 | new_statuses += workflows.find(:all, |
|
|||
51 | :include => :new_status, |
|
49 | :include => :new_status, | |
52 | :conditions => ["role_id=? and tracker_id=?", role.id, tracker.id]).collect{ |w| w.new_status } if role && tracker |
|
50 | :conditions => ["role_id=? and tracker_id=?", role.id, tracker.id]).collect{ |w| w.new_status } if role && tracker | |
53 | new_statuses.sort{|x, y| x.position <=> y.position } |
|
51 | new_statuses.sort{|x, y| x.position <=> y.position } |
General Comments 0
You need to be logged in to leave comments.
Login now