##// END OF EJS Templates
Fixed a regression (crash when an admin with no role on the project try to create an issue)...
Jean-Philippe Lang -
r417:46d67cb349fb
parent child
Show More
@@ -214,7 +214,8 class ProjectsController < ApplicationController
214 @priorities = Enumeration::get_values('IPRI')
214 @priorities = Enumeration::get_values('IPRI')
215
215
216 default_status = IssueStatus.default
216 default_status = IssueStatus.default
217 @issue = Issue.new(:project => @project, :tracker => @tracker, :status => default_status)
217 @issue = Issue.new(:project => @project, :tracker => @tracker)
218 @issue.status = default_status
218 @allowed_statuses = default_status.find_new_statuses_allowed_to(logged_in_user.role_for_project(@project), @issue.tracker) if logged_in_user
219 @allowed_statuses = default_status.find_new_statuses_allowed_to(logged_in_user.role_for_project(@project), @issue.tracker) if logged_in_user
219 if request.get?
220 if request.get?
220 @issue.start_date = Date.today
221 @issue.start_date = Date.today
@@ -38,16 +38,18 class IssueStatus < ActiveRecord::Base
38 # Returns an array of all statuses the given role can switch to
38 # Returns an array of all statuses the given role can switch to
39 # Uses association cache when called more than one time
39 # Uses association cache when called more than one time
40 def new_statuses_allowed_to(role, tracker)
40 def new_statuses_allowed_to(role, tracker)
41 new_statuses = [self] + workflows.select {|w| w.role_id == role.id && w.tracker_id == tracker.id}.collect{|w| w.new_status}
41 new_statuses = [self]
42 new_statuses += workflows.select {|w| w.role_id == role.id && w.tracker_id == tracker.id}.collect{|w| w.new_status} if role && tracker
42 new_statuses.sort{|x, y| x.position <=> y.position }
43 new_statuses.sort{|x, y| x.position <=> y.position }
43 end
44 end
44
45
45 # Same thing as above but uses a database query
46 # Same thing as above but uses a database query
46 # More efficient than the previous method if called just once
47 # More efficient than the previous method if called just once
47 def find_new_statuses_allowed_to(role, tracker)
48 def find_new_statuses_allowed_to(role, tracker)
48 new_statuses = [self] + workflows.find(:all,
49 new_statuses = [self]
49 :include => :new_status,
50 new_statuses += workflows.find(:all,
50 :conditions => ["role_id=? and tracker_id=?", role.id, tracker.id]).collect{ |w| w.new_status }
51 :include => :new_status,
52 :conditions => ["role_id=? and tracker_id=?", role.id, tracker.id]).collect{ |w| w.new_status } if role && tracker
51 new_statuses.sort{|x, y| x.position <=> y.position }
53 new_statuses.sort{|x, y| x.position <=> y.position }
52 end
54 end
53
55
General Comments 0
You need to be logged in to leave comments. Login now