Actions
Feature #35507
closedAPI to close/reopen projects
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
Related issues
Updated by Go MAEDA over 3 years ago
- Related to Feature #13725: Archive/close a project via API added
Updated by Yuichi HARADA over 3 years ago
- File 35507.patch 35507.patch added
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
Updated by Go MAEDA over 3 years ago
- Target version set to Candidate for next major release
Updated by Go MAEDA over 3 years ago
- Target version changed from Candidate for next major release to 5.0.0
Setting the target version to 5.0.0.
Updated by Go MAEDA over 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