Adds projects bulk delete (#36691).

Patch by Jens Krämer. 


git-svn-id: https://svn.redmine.org/redmine/trunk@21592 e93f8b46-1217-0410-a6f0-8f06a7374b81
This commit is contained in:
Marius Balteanu
2022-05-17 20:50:37 +00:00
parent 883aa3b5cc
commit e1d6bfbdcc
8 changed files with 181 additions and 4 deletions

View File

@@ -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