summaryrefslogtreecommitdiffstats
path: root/app/controllers/projects_controller.rb
diff options
context:
space:
mode:
authorJean-Philippe Lang <jp_lang@yahoo.fr>2015-01-07 22:19:57 +0000
committerJean-Philippe Lang <jp_lang@yahoo.fr>2015-01-07 22:19:57 +0000
commit5d2eea14893b509f0f9044a53270bd84b4e06acb (patch)
treef213e30964bedf3d39dfd18d3032dd446d8a84a2 /app/controllers/projects_controller.rb
parentb7ad1e82cc6b88346b06f178df425667bd95e2c3 (diff)
downloadredmine-5d2eea14893b509f0f9044a53270bd84b4e06acb.tar.gz
redmine-5d2eea14893b509f0f9044a53270bd84b4e06acb.zip
Cleans up parent project assignment in ProjectsController.
git-svn-id: http://svn.redmine.org/redmine/trunk@13847 e93f8b46-1217-0410-a6f0-8f06a7374b81
Diffstat (limited to 'app/controllers/projects_controller.rb')
-rw-r--r--app/controllers/projects_controller.rb26
1 files changed, 3 insertions, 23 deletions
diff --git a/app/controllers/projects_controller.rb b/app/controllers/projects_controller.rb
index 747212927..85848f513 100644
--- a/app/controllers/projects_controller.rb
+++ b/app/controllers/projects_controller.rb
@@ -74,8 +74,7 @@ class ProjectsController < ApplicationController
@project = Project.new
@project.safe_attributes = params[:project]
- if validate_parent_id && @project.save
- @project.set_allowed_parent!(params[:project]['parent_id']) if params[:project].has_key?('parent_id')
+ if @project.save
unless User.current.admin?
@project.add_default_member(User.current)
end
@@ -110,8 +109,7 @@ class ProjectsController < ApplicationController
Mailer.with_deliveries(params[:notifications] == '1') do
@project = Project.new
@project.safe_attributes = params[:project]
- if validate_parent_id && @project.copy(@source_project, :only => params[:only])
- @project.set_allowed_parent!(params[:project]['parent_id']) if params[:project].has_key?('parent_id')
+ if @project.copy(@source_project, :only => params[:only])
flash[:notice] = l(:notice_successful_create)
redirect_to settings_project_path(@project)
elsif !@project.new_record?
@@ -170,8 +168,7 @@ class ProjectsController < ApplicationController
def update
@project.safe_attributes = params[:project]
- if validate_parent_id && @project.save
- @project.set_allowed_parent!(params[:project]['parent_id']) if params[:project].has_key?('parent_id')
+ if @project.save
respond_to do |format|
format.html {
flash[:notice] = l(:notice_successful_update)
@@ -233,21 +230,4 @@ class ProjectsController < ApplicationController
# hide project in layout
@project = nil
end
-
- private
-
- # Validates parent_id param according to user's permissions
- # TODO: move it to Project model in a validation that depends on User.current
- def validate_parent_id
- return true if User.current.admin?
- parent_id = params[:project] && params[:project][:parent_id]
- if parent_id || @project.new_record?
- parent = parent_id.blank? ? nil : Project.find_by_id(parent_id.to_i)
- unless @project.allowed_parents.include?(parent)
- @project.errors.add :parent_id, :invalid
- return false
- end
- end
- true
- end
end