Commit 18c82265 authored by Dmitriy Zaporozhets's avatar Dmitriy Zaporozhets

Refactor project fork service

Signed-off-by: default avatarDmitriy Zaporozhets <dmitriy.zaporozhets@gmail.com>
parent 58011d61
...@@ -13,11 +13,14 @@ module Projects ...@@ -13,11 +13,14 @@ module Projects
project = Project.new(project_params) project = Project.new(project_params)
project.name = @from_project.name project.name = @from_project.name
project.path = @from_project.path project.path = @from_project.path
project.namespace = @current_user.namespace project.creator = @current_user
if namespace = @params[:namespace] if namespace = @params[:namespace]
project.namespace = namespace project.namespace = namespace
else
project.namespace = @current_user.namespace
end end
project.creator = @current_user
unless @current_user.can?(:create_projects, project.namespace) unless @current_user.can?(:create_projects, project.namespace)
project.errors.add(:namespace, 'insufficient access rights') project.errors.add(:namespace, 'insufficient access rights')
return project return project
...@@ -47,8 +50,8 @@ module Projects ...@@ -47,8 +50,8 @@ module Projects
else else
project.errors.add(:base, "Invalid fork destination") project.errors.add(:base, "Invalid fork destination")
end end
project
project
end end
end end
end end
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment