summaryrefslogtreecommitdiffstats
path: root/app/models/issue_status.rb
diff options
context:
space:
mode:
authorJean-Philippe Lang <jp_lang@yahoo.fr>2015-07-26 08:30:19 +0000
committerJean-Philippe Lang <jp_lang@yahoo.fr>2015-07-26 08:30:19 +0000
commit2bc5b60f9de7c533b33348213f6ddac37dc9cdb3 (patch)
tree803c2d2ece43283b231b59ede3636c9fc2d3828a /app/models/issue_status.rb
parentfdecb2a17b450c4524856b0286c2ec27ef113ea6 (diff)
downloadredmine-2bc5b60f9de7c533b33348213f6ddac37dc9cdb3.tar.gz
redmine-2bc5b60f9de7c533b33348213f6ddac37dc9cdb3.zip
Makes new issue initial status settable in workflow (#5816).
git-svn-id: http://svn.redmine.org/redmine/trunk@14458 e93f8b46-1217-0410-a6f0-8f06a7374b81
Diffstat (limited to 'app/models/issue_status.rb')
-rw-r--r--app/models/issue_status.rb22
1 files changed, 6 insertions, 16 deletions
diff --git a/app/models/issue_status.rb b/app/models/issue_status.rb
index 4e9b2ce87..e39d69a76 100644
--- a/app/models/issue_status.rb
+++ b/app/models/issue_status.rb
@@ -45,28 +45,18 @@ class IssueStatus < ActiveRecord::Base
end
# 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, author=false, assignee=false)
- if roles && tracker
- role_ids = roles.collect(&:id)
- transitions = workflows.select do |w|
- role_ids.include?(w.role_id) &&
- w.tracker_id == tracker.id &&
- ((!w.author && !w.assignee) || (author && w.author) || (assignee && w.assignee))
- end
- transitions.map(&:new_status).compact.sort
- else
- []
- end
+ self.class.new_statuses_allowed(self, roles, tracker, author, assignee)
end
+ alias :find_new_statuses_allowed_to :new_statuses_allowed_to
- # 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, author=false, assignee=false)
+ def self.new_statuses_allowed(status, roles, tracker, author=false, assignee=false)
if roles.present? && tracker
+ status_id = status.try(:id) || 0
+
scope = IssueStatus.
joins(:workflow_transitions_as_new_status).
- where(:workflows => {:old_status_id => id, :role_id => roles.map(&:id), :tracker_id => tracker.id})
+ where(:workflows => {:old_status_id => status_id, :role_id => roles.map(&:id), :tracker_id => tracker.id})
unless author && assignee
if author || assignee