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