From 41163fd55251edbfa0d0dd341e34c878563e4981 Mon Sep 17 00:00:00 2001 From: James Lopez Date: Thu, 14 Apr 2016 18:01:21 +0200 Subject: some experimental UI stuff to test export --- app/controllers/projects_controller.rb | 9 +++++++++ 1 file changed, 9 insertions(+) (limited to 'app/controllers/projects_controller.rb') diff --git a/app/controllers/projects_controller.rb b/app/controllers/projects_controller.rb index 3cc37e59855..39ae3659a82 100644 --- a/app/controllers/projects_controller.rb +++ b/app/controllers/projects_controller.rb @@ -186,6 +186,15 @@ class ProjectsController < Projects::ApplicationController ) end + def export + ::Projects::ImportExport::ExportService.new(@project, current_user).execute + + redirect_to( + project_path(@project), + notice: "Project export successfully started" + ) + end + def toggle_star current_user.toggle_star(@project) @project.reload -- cgit v1.2.1 From 05edd5e6dc169e4987e5e98e9243fa85c5b6e4b8 Mon Sep 17 00:00:00 2001 From: James Lopez Date: Fri, 15 Apr 2016 15:38:34 +0200 Subject: download export now working --- app/controllers/projects_controller.rb | 11 ++++++++++- 1 file changed, 10 insertions(+), 1 deletion(-) (limited to 'app/controllers/projects_controller.rb') diff --git a/app/controllers/projects_controller.rb b/app/controllers/projects_controller.rb index 39ae3659a82..9fb4370ef90 100644 --- a/app/controllers/projects_controller.rb +++ b/app/controllers/projects_controller.rb @@ -190,11 +190,15 @@ class ProjectsController < Projects::ApplicationController ::Projects::ImportExport::ExportService.new(@project, current_user).execute redirect_to( - project_path(@project), + edit_project_path(@project), notice: "Project export successfully started" ) end + def download_export + send_file export_project_path, disposition: 'attachment' + end + def toggle_star current_user.toggle_star(@project) @project.reload @@ -256,4 +260,9 @@ class ProjectsController < Projects::ApplicationController def get_id project.repository.root_ref end + + def export_project_path + # TODO: move this, probably to ImportExport and refactor + File.join(Settings.shared['path'], 'tmp/project_exports', @project.path_with_namespace, 'project.tar.gz') + end end -- cgit v1.2.1 From c5bc262981a9fbfe748dfb0b527e4fb0fa597ccf Mon Sep 17 00:00:00 2001 From: James Lopez Date: Thu, 28 Apr 2016 18:00:30 +0200 Subject: few fixes - import from UI working --- app/controllers/projects_controller.rb | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) (limited to 'app/controllers/projects_controller.rb') diff --git a/app/controllers/projects_controller.rb b/app/controllers/projects_controller.rb index 1d4684ca22e..62f8b376c18 100644 --- a/app/controllers/projects_controller.rb +++ b/app/controllers/projects_controller.rb @@ -191,6 +191,7 @@ class ProjectsController < Projects::ApplicationController end def export + #TODO: Move to worker ::Projects::ImportExport::ExportService.new(@project, current_user).execute redirect_to( @@ -267,6 +268,7 @@ class ProjectsController < Projects::ApplicationController def export_project_path # TODO: move this, probably to ImportExport and refactor - File.join(Settings.shared['path'], 'tmp/project_exports', @project.path_with_namespace, 'project.tar.gz') + folder = File.join(Settings.shared['path'], 'tmp/project_exports', @project.path_with_namespace) + Dir.glob("#{folder}/*export.tar.gz").max_by {|f| File.ctime(f)} end end -- cgit v1.2.1 From bd2ebf37e6c5aa07f8d29f4ac8c88fc8333a2297 Mon Sep 17 00:00:00 2001 From: James Lopez Date: Wed, 4 May 2016 10:57:09 +0200 Subject: use worker in controller --- app/controllers/projects_controller.rb | 9 ++++++--- 1 file changed, 6 insertions(+), 3 deletions(-) (limited to 'app/controllers/projects_controller.rb') diff --git a/app/controllers/projects_controller.rb b/app/controllers/projects_controller.rb index 62f8b376c18..f15f20dcf52 100644 --- a/app/controllers/projects_controller.rb +++ b/app/controllers/projects_controller.rb @@ -191,8 +191,7 @@ class ProjectsController < Projects::ApplicationController end def export - #TODO: Move to worker - ::Projects::ImportExport::ExportService.new(@project, current_user).execute + @project.add_export_job(current_user_id: current_user.id) redirect_to( edit_project_path(@project), @@ -201,7 +200,11 @@ class ProjectsController < Projects::ApplicationController end def download_export - send_file export_project_path, disposition: 'attachment' + if export_project_path + send_file export_project_path, disposition: 'attachment' + else + render_404 + end end def toggle_star -- cgit v1.2.1 From 8c508037a63ba2b82d56757bce011ac53a073ae6 Mon Sep 17 00:00:00 2001 From: James Lopez Date: Fri, 13 May 2016 17:03:03 +0200 Subject: updated controllers with permissions check --- app/controllers/projects_controller.rb | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'app/controllers/projects_controller.rb') diff --git a/app/controllers/projects_controller.rb b/app/controllers/projects_controller.rb index f15f20dcf52..980cae65f84 100644 --- a/app/controllers/projects_controller.rb +++ b/app/controllers/projects_controller.rb @@ -7,7 +7,7 @@ class ProjectsController < Projects::ApplicationController before_action :assign_ref_vars, :tree, only: [:show], if: :repo_exists? # Authorize - before_action :authorize_admin_project!, only: [:edit, :update, :housekeeping] + before_action :authorize_admin_project!, only: [:edit, :update, :housekeeping, :download_export, :export] before_action :event_filter, only: [:show, :activity] layout :determine_layout -- cgit v1.2.1 From 3f7ed550110daaec8a76af7146b701dfc0210e60 Mon Sep 17 00:00:00 2001 From: James Lopez Date: Tue, 14 Jun 2016 12:47:07 +0200 Subject: lots of refactoring to reuse import service --- app/controllers/projects_controller.rb | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'app/controllers/projects_controller.rb') diff --git a/app/controllers/projects_controller.rb b/app/controllers/projects_controller.rb index 5c657290046..a1d58144399 100644 --- a/app/controllers/projects_controller.rb +++ b/app/controllers/projects_controller.rb @@ -190,7 +190,7 @@ class ProjectsController < Projects::ApplicationController redirect_to( edit_project_path(@project), - notice: "Project export successfully started" + notice: "Project export successfully started." ) end -- cgit v1.2.1 From 9ecebaaea16d206ed20a2f4fc0021a2145c873f5 Mon Sep 17 00:00:00 2001 From: James Lopez Date: Tue, 14 Jun 2016 16:31:03 +0200 Subject: adding notifications stuff and more refactoring for exporting projects --- app/controllers/projects_controller.rb | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'app/controllers/projects_controller.rb') diff --git a/app/controllers/projects_controller.rb b/app/controllers/projects_controller.rb index a1d58144399..9a6d4be2fc8 100644 --- a/app/controllers/projects_controller.rb +++ b/app/controllers/projects_controller.rb @@ -190,7 +190,7 @@ class ProjectsController < Projects::ApplicationController redirect_to( edit_project_path(@project), - notice: "Project export successfully started." + notice: "Project export started." ) end -- cgit v1.2.1 From 36ccaca35a7be19498d779a5b781cc4e3f0dede8 Mon Sep 17 00:00:00 2001 From: James Lopez Date: Tue, 14 Jun 2016 22:11:21 +0200 Subject: project export archiver --- app/controllers/projects_controller.rb | 4 +--- 1 file changed, 1 insertion(+), 3 deletions(-) (limited to 'app/controllers/projects_controller.rb') diff --git a/app/controllers/projects_controller.rb b/app/controllers/projects_controller.rb index 9a6d4be2fc8..affc298e0ca 100644 --- a/app/controllers/projects_controller.rb +++ b/app/controllers/projects_controller.rb @@ -266,8 +266,6 @@ class ProjectsController < Projects::ApplicationController end def export_project_path - # TODO: move this, probably to ImportExport and refactor - folder = File.join(Settings.shared['path'], 'tmp/project_exports', @project.path_with_namespace) - Dir.glob("#{folder}/*export.tar.gz").max_by {|f| File.ctime(f)} + Dir.glob("#{@project.export_path}/*export.tar.gz").max_by {|f| File.ctime(f)} end end -- cgit v1.2.1 From 4bde59341f6d4679b2eefa2c5e332c33c3c76050 Mon Sep 17 00:00:00 2001 From: James Lopez Date: Wed, 15 Jun 2016 17:31:00 +0200 Subject: lots of refactoring again based on feedback. Changed the UI slightly and also fixed a small bug --- app/controllers/projects_controller.rb | 31 +++++++++++++++++++++++-------- 1 file changed, 23 insertions(+), 8 deletions(-) (limited to 'app/controllers/projects_controller.rb') diff --git a/app/controllers/projects_controller.rb b/app/controllers/projects_controller.rb index affc298e0ca..af357ae9a71 100644 --- a/app/controllers/projects_controller.rb +++ b/app/controllers/projects_controller.rb @@ -7,7 +7,7 @@ class ProjectsController < Projects::ApplicationController before_action :assign_ref_vars, :tree, only: [:show], if: :repo_exists? # Authorize - before_action :authorize_admin_project!, only: [:edit, :update, :housekeeping, :download_export, :export] + before_action :authorize_admin_project!, only: [:edit, :update, :housekeeping, :download_export, :export, :remove_export] before_action :event_filter, only: [:show, :activity] layout :determine_layout @@ -186,19 +186,38 @@ class ProjectsController < Projects::ApplicationController end def export - @project.add_export_job(current_user_id: current_user.id) + @project.add_export_job(current_user: current_user) redirect_to( edit_project_path(@project), - notice: "Project export started." + notice: "Project export started. A download link will be sent by e-mail." ) end def download_export + export_project_path = @project.export_project_path + if export_project_path send_file export_project_path, disposition: 'attachment' else - render_404 + redirect_to( + edit_project_path(@project), + alert: "Project export link has expired. Please generate a new export from your project settings." + ) + end + end + + def remove_export + if @project.remove_exports + redirect_to( + edit_project_path(@project), + notice: "Project export has been deleted." + ) + else + redirect_to( + edit_project_path(@project), + alert: "Project export could not be deleted." + ) end end @@ -264,8 +283,4 @@ class ProjectsController < Projects::ApplicationController def get_id project.repository.root_ref end - - def export_project_path - Dir.glob("#{@project.export_path}/*export.tar.gz").max_by {|f| File.ctime(f)} - end end -- cgit v1.2.1 From 2d4556c5d208e9ae805b0467c1c7281ae6a36ebe Mon Sep 17 00:00:00 2001 From: James Lopez Date: Fri, 17 Jun 2016 15:47:00 +0200 Subject: a few changes based on MR feedback --- app/controllers/projects_controller.rb | 18 ++++++++++++------ 1 file changed, 12 insertions(+), 6 deletions(-) (limited to 'app/controllers/projects_controller.rb') diff --git a/app/controllers/projects_controller.rb b/app/controllers/projects_controller.rb index af357ae9a71..673adca6ade 100644 --- a/app/controllers/projects_controller.rb +++ b/app/controllers/projects_controller.rb @@ -7,7 +7,7 @@ class ProjectsController < Projects::ApplicationController before_action :assign_ref_vars, :tree, only: [:show], if: :repo_exists? # Authorize - before_action :authorize_admin_project!, only: [:edit, :update, :housekeeping, :download_export, :export, :remove_export] + before_action :authorize_admin_project!, only: [:edit, :update, :housekeeping, :download_export, :export, :remove_export, :generate_new_export] before_action :event_filter, only: [:show, :activity] layout :determine_layout @@ -190,7 +190,7 @@ class ProjectsController < Projects::ApplicationController redirect_to( edit_project_path(@project), - notice: "Project export started. A download link will be sent by e-mail." + notice: "Project export started. A download link will be sent by email." ) end @@ -209,10 +209,16 @@ class ProjectsController < Projects::ApplicationController def remove_export if @project.remove_exports - redirect_to( - edit_project_path(@project), - notice: "Project export has been deleted." - ) + flash[:notice] = "Project export has been deleted." + else + flash[:alert] = "Project export could not be deleted." + end + redirect_to(edit_project_path(@project)) + end + + def generate_new_export + if @project.remove_exports + export else redirect_to( edit_project_path(@project), -- cgit v1.2.1