Fixed that improper statuses are proposed when changing status before tracker on the issue form (#10619).

git-svn-id: svn+ssh://rubyforge.org/var/svn/redmine/trunk@9378 e93f8b46-1217-0410-a6f0-8f06a7374b81
This commit is contained in:
Jean-Philippe Lang
2012-04-09 09:39:27 +00:00
parent 6d62ab64e6
commit ea307619be
3 changed files with 47 additions and 6 deletions

View File

@@ -509,17 +509,25 @@ class Issue < ActiveRecord::Base
!relations_to.detect {|ir| ir.relation_type == 'blocks' && !ir.issue_from.closed?}.nil?
end
# Returns an array of status that user is able to apply
# Returns an array of statuses that user is able to apply
def new_statuses_allowed_to(user=User.current, include_default=false)
statuses = status.find_new_statuses_allowed_to(
initial_status = nil
if new_record?
initial_status = IssueStatus.default
elsif status_id_was
initial_status = IssueStatus.find_by_id(status_id_was)
end
initial_status ||= status
statuses = initial_status.find_new_statuses_allowed_to(
user.admin ? Role.all : user.roles_for_project(project),
tracker,
author == user,
assigned_to_id_changed? ? assigned_to_id_was == user.id : assigned_to_id == user.id
)
statuses << status unless statuses.empty?
statuses << initial_status unless statuses.empty?
statuses << IssueStatus.default if include_default
statuses = statuses.uniq.sort
statuses = statuses.compact.uniq.sort
blocked? ? statuses.reject {|s| s.is_closed?} : statuses
end