summaryrefslogtreecommitdiffstats
path: root/app/controllers/projects_controller.rb
diff options
context:
space:
mode:
Diffstat (limited to 'app/controllers/projects_controller.rb')
-rw-r--r--app/controllers/projects_controller.rb25
1 files changed, 21 insertions, 4 deletions
diff --git a/app/controllers/projects_controller.rb b/app/controllers/projects_controller.rb
index d8b2e8b9a..695ca1dec 100644
--- a/app/controllers/projects_controller.rb
+++ b/app/controllers/projects_controller.rb
@@ -23,16 +23,16 @@ class ProjectsController < ApplicationController
menu_item :projects, :only => [:index, :new, :copy, :create]
before_action :find_project,
- :except => [:index, :autocomplete, :list, :new, :create, :copy]
+ :except => [:index, :autocomplete, :list, :new, :create, :copy, :bulk_destroy]
before_action :authorize,
:except => [:index, :autocomplete, :list, :new, :create, :copy,
:archive, :unarchive,
- :destroy]
+ :destroy, :bulk_destroy]
before_action :authorize_global, :only => [:new, :create]
- before_action :require_admin, :only => [:copy, :archive, :unarchive]
+ before_action :require_admin, :only => [:copy, :archive, :unarchive, :bulk_destroy]
accept_atom_auth :index
accept_api_auth :index, :show, :create, :update, :destroy, :archive, :unarchive, :close, :reopen
- require_sudo_mode :destroy
+ require_sudo_mode :destroy, :bulk_destroy
helper :custom_fields
helper :issues
@@ -315,6 +315,23 @@ class ProjectsController < ApplicationController
@project = nil
end
+ # Delete selected projects
+ def bulk_destroy
+ @projects = Project.where(id: params[:ids]).
+ where.not(status: Project::STATUS_SCHEDULED_FOR_DELETION).to_a
+
+ if @projects.empty?
+ render_404
+ return
+ end
+
+ if params[:confirm] == I18n.t(:general_text_Yes)
+ DestroyProjectsJob.schedule @projects
+ flash[:notice] = l(:notice_successful_delete)
+ redirect_to admin_projects_path
+ end
+ end
+
private
# Returns the ProjectEntry scope for index