Fixed a regression (crash when an admin with no role on the project try to create an issue)
git-svn-id: http://redmine.rubyforge.org/svn/trunk@420 e93f8b46-1217-0410-a6f0-8f06a7374b81
This commit is contained in:
parent
f7d5141251
commit
46d67cb349
@ -214,7 +214,8 @@ class ProjectsController < ApplicationController
|
|||||||
@priorities = Enumeration::get_values('IPRI')
|
@priorities = Enumeration::get_values('IPRI')
|
||||||
|
|
||||||
default_status = IssueStatus.default
|
default_status = IssueStatus.default
|
||||||
@issue = Issue.new(:project => @project, :tracker => @tracker, :status => default_status)
|
@issue = Issue.new(:project => @project, :tracker => @tracker)
|
||||||
|
@issue.status = default_status
|
||||||
@allowed_statuses = default_status.find_new_statuses_allowed_to(logged_in_user.role_for_project(@project), @issue.tracker) if logged_in_user
|
@allowed_statuses = default_status.find_new_statuses_allowed_to(logged_in_user.role_for_project(@project), @issue.tracker) if logged_in_user
|
||||||
if request.get?
|
if request.get?
|
||||||
@issue.start_date = Date.today
|
@issue.start_date = Date.today
|
||||||
|
@ -38,16 +38,18 @@ class IssueStatus < ActiveRecord::Base
|
|||||||
# Returns an array of all statuses the given role can switch to
|
# Returns an array of all statuses the given role can switch to
|
||||||
# Uses association cache when called more than one time
|
# Uses association cache when called more than one time
|
||||||
def new_statuses_allowed_to(role, tracker)
|
def new_statuses_allowed_to(role, tracker)
|
||||||
new_statuses = [self] + workflows.select {|w| w.role_id == role.id && w.tracker_id == tracker.id}.collect{|w| w.new_status}
|
new_statuses = [self]
|
||||||
|
new_statuses += workflows.select {|w| w.role_id == role.id && w.tracker_id == tracker.id}.collect{|w| w.new_status} if role && tracker
|
||||||
new_statuses.sort{|x, y| x.position <=> y.position }
|
new_statuses.sort{|x, y| x.position <=> y.position }
|
||||||
end
|
end
|
||||||
|
|
||||||
# Same thing as above but uses a database query
|
# Same thing as above but uses a database query
|
||||||
# More efficient than the previous method if called just once
|
# More efficient than the previous method if called just once
|
||||||
def find_new_statuses_allowed_to(role, tracker)
|
def find_new_statuses_allowed_to(role, tracker)
|
||||||
new_statuses = [self] + workflows.find(:all,
|
new_statuses = [self]
|
||||||
:include => :new_status,
|
new_statuses += workflows.find(:all,
|
||||||
:conditions => ["role_id=? and tracker_id=?", role.id, tracker.id]).collect{ |w| w.new_status }
|
:include => :new_status,
|
||||||
|
:conditions => ["role_id=? and tracker_id=?", role.id, tracker.id]).collect{ |w| w.new_status } if role && tracker
|
||||||
new_statuses.sort{|x, y| x.position <=> y.position }
|
new_statuses.sort{|x, y| x.position <=> y.position }
|
||||||
end
|
end
|
||||||
|
|
||||||
|
Loading…
x
Reference in New Issue
Block a user