Welcome to mirror list, hosted at ThFree Co, Russian Federation.

gitlab.com/gitlab-org/gitlab-foss.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorDmitriy Zaporozhets <dmitriy.zaporozhets@gmail.com>2014-11-30 01:50:25 +0300
committerDmitriy Zaporozhets <dmitriy.zaporozhets@gmail.com>2014-11-30 01:50:25 +0300
commit9d937293136afd7994218b8dc72bb0956fb19eeb (patch)
tree51e69d234bb71ba46fac6053a070762963a0f67c /app/controllers/projects/imports_controller.rb
parenta8df4ee9e2b7881cea46ebc6b3e7889d13e3b5e5 (diff)
Move projects import to separate resource. Add bare repo creation to repository controller
Signed-off-by: Dmitriy Zaporozhets <dmitriy.zaporozhets@gmail.com>
Diffstat (limited to 'app/controllers/projects/imports_controller.rb')
-rw-r--r--app/controllers/projects/imports_controller.rb49
1 files changed, 49 insertions, 0 deletions
diff --git a/app/controllers/projects/imports_controller.rb b/app/controllers/projects/imports_controller.rb
new file mode 100644
index 00000000000..b8350642804
--- /dev/null
+++ b/app/controllers/projects/imports_controller.rb
@@ -0,0 +1,49 @@
+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
+
+ redirect_to project_import_path(@project)
+ end
+
+ def show
+ unless @project.import_in_progress?
+ if @project.import_finished?
+ redirect_to(@project) and return
+ else
+ redirect_to new_project_import_path(@project) and return
+ end
+ end
+ end
+
+ private
+
+ def require_no_repo
+ if @project.repository_exists?
+ redirect_to(@project) and return
+ end
+ end
+
+ def redirect_if_progress
+ if @project.import_in_progress?
+ redirect_to project_import_path(@project) and return
+ end
+ end
+end