summaryrefslogtreecommitdiffstats
path: root/app/models/project.rb
diff options
context:
space:
mode:
authorJean-Philippe Lang <jp_lang@yahoo.fr>2015-09-21 20:32:11 +0000
committerJean-Philippe Lang <jp_lang@yahoo.fr>2015-09-21 20:32:11 +0000
commit64a80066bd8681f477f675a960f2b258c285044c (patch)
tree72f38eeb36302ce61035a5135a0b1496e7a6d590 /app/models/project.rb
parentaa096cb0cc96c0b7f12274dcf7bbd3d8e3e44948 (diff)
downloadredmine-64a80066bd8681f477f675a960f2b258c285044c.tar.gz
redmine-64a80066bd8681f477f675a960f2b258c285044c.zip
Error message when editing a child project without add project/subprojects permissions (#20282).
git-svn-id: http://svn.redmine.org/redmine/trunk@14619 e93f8b46-1217-0410-a6f0-8f06a7374b81
Diffstat (limited to 'app/models/project.rb')
-rw-r--r--app/models/project.rb14
1 files changed, 8 insertions, 6 deletions
diff --git a/app/models/project.rb b/app/models/project.rb
index 18c4a20c9..2704be247 100644
--- a/app/models/project.rb
+++ b/app/models/project.rb
@@ -700,12 +700,14 @@ class Project < ActiveRecord::Base
attrs = attrs.deep_dup
@unallowed_parent_id = nil
- parent_id_param = attrs['parent_id'].to_s
- if parent_id_param.blank? || parent_id_param != parent_id.to_s
- p = parent_id_param.present? ? Project.find_by_id(parent_id_param) : nil
- unless allowed_parents(user).include?(p)
- attrs.delete('parent_id')
- @unallowed_parent_id = true
+ if new_record? || attrs.key?('parent_id')
+ parent_id_param = attrs['parent_id'].to_s
+ if new_record? || parent_id_param != parent_id.to_s
+ p = parent_id_param.present? ? Project.find_by_id(parent_id_param) : nil
+ unless allowed_parents(user).include?(p)
+ attrs.delete('parent_id')
+ @unallowed_parent_id = true
+ end
end
end