debian-mirror-gitlab/app/controllers/projects/forks_controller.rb

25 lines
709 B
Ruby
Raw Normal View History

2015-04-26 12:48:37 +05:30
class Projects::ForksController < Projects::ApplicationController
# Authorize
2015-09-11 14:41:01 +05:30
before_action :require_non_empty_project
before_action :authorize_download_code!
2015-04-26 12:48:37 +05:30
def new
@namespaces = current_user.manageable_namespaces
@namespaces.delete(@project.namespace)
end
def create
namespace = Namespace.find(params[:namespace_key])
@forked_project = ::Projects::ForkService.new(project, current_user, namespace: namespace).execute
if @forked_project.saved? && @forked_project.forked?
redirect_to(
namespace_project_path(@forked_project.namespace, @forked_project),
notice: 'Project was successfully forked.'
)
else
render :error
end
end
end