1
0
mirror of https://github.com/meineerde/redmine.git synced 2025-12-26 10:21:14 +00:00

Use scope.

git-svn-id: http://svn.redmine.org/redmine/trunk@13692 e93f8b46-1217-0410-a6f0-8f06a7374b81
This commit is contained in:
Jean-Philippe Lang 2014-12-02 20:23:20 +00:00
parent c3ba302f0d
commit 49bd22255f

View File

@ -368,7 +368,7 @@ class Project < ActiveRecord::Base
# by the current user
def allowed_parents
return @allowed_parents if @allowed_parents
@allowed_parents = Project.where(Project.allowed_to_condition(User.current, :add_subprojects)).to_a
@allowed_parents = Project.allowed_to(User.current, :add_subprojects).to_a
@allowed_parents = @allowed_parents - self_and_descendants
if User.current.allowed_to?(:add_project, nil, :global => true) || (!new_record? && parent.nil?)
@allowed_parents << nil