@@ -18,6 +18,7 | |||||
18 | class IssueStatus < ActiveRecord::Base |
|
18 | class IssueStatus < ActiveRecord::Base | |
19 | before_destroy :check_integrity |
|
19 | before_destroy :check_integrity | |
20 | has_many :workflows, :class_name => 'WorkflowTransition', :foreign_key => "old_status_id" |
|
20 | has_many :workflows, :class_name => 'WorkflowTransition', :foreign_key => "old_status_id" | |
|
21 | has_many :workflow_transitions_as_new_status, :class_name => 'WorkflowTransition', :foreign_key => "new_status_id" | |||
21 | acts_as_list |
|
22 | acts_as_list | |
22 |
|
23 | |||
23 | before_destroy :delete_workflow_rules |
|
24 | before_destroy :delete_workflow_rules | |
@@ -72,16 +73,19 class IssueStatus < ActiveRecord::Base | |||||
72 | # More efficient than the previous method if called just once |
|
73 | # More efficient than the previous method if called just once | |
73 | def find_new_statuses_allowed_to(roles, tracker, author=false, assignee=false) |
|
74 | def find_new_statuses_allowed_to(roles, tracker, author=false, assignee=false) | |
74 | if roles.present? && tracker |
|
75 | if roles.present? && tracker | |
75 | conditions = "(author = :false AND assignee = :false)" |
|
76 | scope = IssueStatus. | |
76 | conditions << " OR author = :true" if author |
|
77 | joins(:workflow_transitions_as_new_status). | |
77 | conditions << " OR assignee = :true" if assignee |
|
78 | where(:workflows => {:old_status_id => id, :role_id => roles.map(&:id), :tracker_id => tracker.id}) | |
78 |
|
79 | |||
79 | workflows. |
|
80 | unless author && assignee | |
80 | includes(:new_status). |
|
81 | if author || assignee | |
81 | where(["role_id IN (:role_ids) AND tracker_id = :tracker_id AND (#{conditions})", |
|
82 | scope = scope.where("author = ? OR assignee = ?", author, assignee) | |
82 | {:role_ids => roles.collect(&:id), :tracker_id => tracker.id, :true => true, :false => false} |
|
83 | else | |
83 | ]).to_a. |
|
84 | scope = scope.where("author = ? AND assignee = ?", false, false) | |
84 | map(&:new_status).compact.sort |
|
85 | end | |
|
86 | end | |||
|
87 | ||||
|
88 | scope.uniq.to_a.sort | |||
85 | else |
|
89 | else | |
86 | [] |
|
90 | [] | |
87 | end |
|
91 | end |
General Comments 0
You need to be logged in to leave comments.
Login now