Refactor: use the existing Issue#new_statuses_allowed_to method.

git-svn-id: svn+ssh://rubyforge.org/var/svn/redmine/trunk@3533 e93f8b46-1217-0410-a6f0-8f06a7374b81
This commit is contained in:
Eric Davis 2010-03-04 00:58:52 +00:00
parent cdb86d5ef7
commit 976cba0c5d
2 changed files with 3 additions and 2 deletions

View File

@ -148,7 +148,7 @@ class IssuesController < ApplicationController
return
end
@issue.status = default_status
@allowed_statuses = ([default_status] + default_status.find_new_statuses_allowed_to(User.current.roles_for_project(@project), @issue.tracker)).uniq
@allowed_statuses = @issue.new_statuses_allowed_to(User.current, true)
if request.get? || request.xhr?
@issue.start_date ||= Date.today

View File

@ -312,9 +312,10 @@ class Issue < ActiveRecord::Base
end
# Returns an array of status that user is able to apply
def new_statuses_allowed_to(user)
def new_statuses_allowed_to(user, include_default=false)
statuses = status.find_new_statuses_allowed_to(user.roles_for_project(project), tracker)
statuses << status unless statuses.empty?
statuses << IssueStatus.default if include_default
statuses = statuses.uniq.sort
blocked? ? statuses.reject {|s| s.is_closed?} : statuses
end