Project

General

Profile

Actions

Feature #35507

closed

API to close/reopen projects

Added by Go MAEDA almost 3 years ago. Updated almost 3 years ago.

Status:
Closed
Priority:
Normal
Assignee:
Category:
REST API
Target version:
Start date:
Due date:
% Done:

0%

Estimated time:
Resolution:
Fixed

Description

API to archive/unarchive projects has been implemented for Redmine 5.0.0 (#35420). I think it is better to implement API to close/reopen projects as well.

This is because archive and close of a project are similar choices for admins. Depending on the situation, admins may want to archive a project, or close a project.


Files

35507.patch (2.71 KB) 35507.patch Yuichi HARADA, 2021-07-02 08:31

Related issues

Related to Redmine - Feature #13725: Archive/close a project via APIClosed

Actions
Actions #1

Updated by Go MAEDA almost 3 years ago

Actions #2

Updated by Yuichi HARADA almost 3 years ago

I have added API to close/reopen a project.

diff --git a/app/controllers/projects_controller.rb b/app/controllers/projects_controller.rb
index 9d7d37bb15..445ff840f3 100644
--- a/app/controllers/projects_controller.rb
+++ b/app/controllers/projects_controller.rb
@@ -30,7 +30,7 @@ class ProjectsController < ApplicationController
   before_action :authorize_global, :only => [:new, :create]
   before_action :require_admin, :only => [:copy, :archive, :unarchive]
   accept_rss_auth :index
-  accept_api_auth :index, :show, :create, :update, :destroy, :archive, :unarchive
+  accept_api_auth :index, :show, :create, :update, :destroy, :archive, :unarchive, :close, :reopen
   require_sudo_mode :destroy

   helper :custom_fields
@@ -275,12 +275,18 @@ class ProjectsController < ApplicationController

   def close
     @project.close
-    redirect_to project_path(@project)
+    respond_to do |format|
+      format.html { redirect_to project_path(@project) }
+      format.api { render_api_ok }
+    end
   end

   def reopen
     @project.reopen
-    redirect_to project_path(@project)
+    respond_to do |format|
+      format.html { redirect_to project_path(@project) }
+      format.api { render_api_ok }
+    end
   end

   # Delete @project
diff --git a/config/routes.rb b/config/routes.rb
index 7e5e3eee93..1fd513d00e 100644
--- a/config/routes.rb
+++ b/config/routes.rb
@@ -133,8 +133,8 @@ Rails.application.routes.draw do
       get 'settings(/:tab)', :action => 'settings', :as => 'settings'
       match 'archive', :via => [:post, :put]
       match 'unarchive', :via => [:post, :put]
-      post 'close'
-      post 'reopen'
+      match 'close', :via => [:post, :put]
+      match 'reopen', :via => [:post, :put]
       match 'copy', :via => [:get, :post]
       match 'bookmark', :via => [:delete, :post]
     end
Actions #3

Updated by Go MAEDA almost 3 years ago

  • Target version set to Candidate for next major release
Actions #4

Updated by Go MAEDA almost 3 years ago

  • Target version changed from Candidate for next major release to 5.0.0

Setting the target version to 5.0.0.

Actions #5

Updated by Go MAEDA almost 3 years ago

  • Status changed from New to Closed
  • Assignee set to Go MAEDA
  • Resolution set to Fixed

Committed the patch. Thank you for your contribution.

Actions

Also available in: Atom PDF