2014-11-29 17:50:25 -05:00
|
|
|
class Projects::ImportsController < Projects::ApplicationController
|
|
|
|
# Authorize
|
|
|
|
before_filter :authorize_admin_project!
|
|
|
|
before_filter :require_no_repo
|
|
|
|
before_filter :redirect_if_progress, except: :show
|
|
|
|
|
|
|
|
def new
|
|
|
|
end
|
|
|
|
|
|
|
|
def create
|
|
|
|
@project.import_url = params[:project][:import_url]
|
|
|
|
|
|
|
|
if @project.save
|
|
|
|
@project.reload
|
|
|
|
|
|
|
|
if @project.import_failed?
|
|
|
|
@project.import_retry
|
|
|
|
else
|
|
|
|
@project.import_start
|
|
|
|
end
|
|
|
|
end
|
|
|
|
|
2015-01-24 13:02:58 -05:00
|
|
|
redirect_to namespace_project_import_path(@project.namespace, @project)
|
2014-11-29 17:50:25 -05:00
|
|
|
end
|
|
|
|
|
|
|
|
def show
|
|
|
|
unless @project.import_in_progress?
|
|
|
|
if @project.import_finished?
|
2015-03-02 21:11:50 -05:00
|
|
|
redirect_to(project_path(@project)) and return
|
2014-11-29 17:50:25 -05:00
|
|
|
else
|
2015-01-24 13:02:58 -05:00
|
|
|
redirect_to new_namespace_project_import_path(@project.namespace,
|
|
|
|
@project) && return
|
2014-11-29 17:50:25 -05:00
|
|
|
end
|
|
|
|
end
|
|
|
|
end
|
|
|
|
|
|
|
|
private
|
|
|
|
|
|
|
|
def require_no_repo
|
2015-03-09 19:36:41 -04:00
|
|
|
if @project.repository_exists? && !@project.import_in_progress?
|
2015-01-24 13:02:58 -05:00
|
|
|
redirect_to(namespace_project_path(@project.namespace, @project)) and return
|
2014-11-29 17:50:25 -05:00
|
|
|
end
|
|
|
|
end
|
|
|
|
|
|
|
|
def redirect_if_progress
|
|
|
|
if @project.import_in_progress?
|
2015-01-24 13:02:58 -05:00
|
|
|
redirect_to namespace_project_import_path(@project.namespace, @project) &&
|
|
|
|
return
|
2014-11-29 17:50:25 -05:00
|
|
|
end
|
|
|
|
end
|
|
|
|
end
|