Project

General

Profile

Actions

Maintenance #1949

closed

xmera Omnia - Collection #1826: Maintenance tasks of several components

Maintenance #1739: Support Redmine 5.1.1

Check if projects controller changes will have impact on plugins

Added by liaham about 1 year ago. Updated about 1 year ago.

Status:
Closed
Priority:
Normal
Assignee:
Target version:
-
Start date:
Due date:
% Done:

100%

Estimated time:
Compatible Redmine Version:

Description

Affected plugins:

diff --git a/app/controllers/projects_controller.rb b/app/controllers/projects_controller.rb
index 61e95bd4e..15e9120f8 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
@@ -300,7 +300,8 @@ class ProjectsController < ApplicationController
 
     @project_to_destroy = @project
     if api_request? || params[:confirm] == @project_to_destroy.identifier
-      @project_to_destroy.destroy
+      DestroyProjectJob.schedule(@project_to_destroy)
+      flash[:notice] = l(:notice_successful_delete)
       respond_to do |format|
         format.html do
           redirect_to(
@@ -314,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
Actions #1

Updated by liaham about 1 year ago

  • Tracker changed from Feature to Maintenance
Actions #2

Updated by liaham about 1 year ago

  • Status changed from New to Closed
  • Assignee set to liaham
  • % Done changed from 0 to 100
Actions

Also available in: Atom PDF