Mercurial > hg > soundsoftware-site
comparison 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 |
comparison
equal
deleted
inserted
replaced
244:8972b600f4fb | 245:051f544170fe |
---|---|
48 return Issue.use_status_for_done_ratio? | 48 return Issue.use_status_for_done_ratio? |
49 end | 49 end |
50 | 50 |
51 # Returns an array of all statuses the given role can switch to | 51 # Returns an array of all statuses the given role can switch to |
52 # Uses association cache when called more than one time | 52 # Uses association cache when called more than one time |
53 def new_statuses_allowed_to(roles, tracker) | 53 def new_statuses_allowed_to(roles, tracker, author=false, assignee=false) |
54 if roles && tracker | 54 if roles && tracker |
55 role_ids = roles.collect(&:id) | 55 role_ids = roles.collect(&:id) |
56 new_statuses = workflows.select {|w| role_ids.include?(w.role_id) && w.tracker_id == tracker.id}.collect{|w| w.new_status}.compact.sort | 56 transitions = workflows.select do |w| |
57 role_ids.include?(w.role_id) && | |
58 w.tracker_id == tracker.id && | |
59 (author || !w.author) && | |
60 (assignee || !w.assignee) | |
61 end | |
62 transitions.collect{|w| w.new_status}.compact.sort | |
57 else | 63 else |
58 [] | 64 [] |
59 end | 65 end |
60 end | 66 end |
61 | 67 |
62 # Same thing as above but uses a database query | 68 # Same thing as above but uses a database query |
63 # More efficient than the previous method if called just once | 69 # More efficient than the previous method if called just once |
64 def find_new_statuses_allowed_to(roles, tracker) | 70 def find_new_statuses_allowed_to(roles, tracker, author=false, assignee=false) |
65 if roles && tracker | 71 if roles && tracker |
72 conditions = {:role_id => roles.collect(&:id), :tracker_id => tracker.id} | |
73 conditions[:author] = false unless author | |
74 conditions[:assignee] = false unless assignee | |
75 | |
66 workflows.find(:all, | 76 workflows.find(:all, |
67 :include => :new_status, | 77 :include => :new_status, |
68 :conditions => { :role_id => roles.collect(&:id), | 78 :conditions => conditions).collect{|w| w.new_status}.compact.sort |
69 :tracker_id => tracker.id}).collect{ |w| w.new_status }.compact.sort | |
70 else | 79 else |
71 [] | 80 [] |
72 end | |
73 end | |
74 | |
75 def new_status_allowed_to?(status, roles, tracker) | |
76 if status && roles && tracker | |
77 !workflows.find(:first, :conditions => {:new_status_id => status.id, :role_id => roles.collect(&:id), :tracker_id => tracker.id}).nil? | |
78 else | |
79 false | |
80 end | 81 end |
81 end | 82 end |
82 | 83 |
83 def <=>(status) | 84 def <=>(status) |
84 position <=> status.position | 85 position <=> status.position |