summaryrefslogtreecommitdiffstats
path: root/app/controllers
diff options
context:
space:
mode:
authorGo MAEDA <maeda@farend.jp>2021-06-24 13:55:06 +0000
committerGo MAEDA <maeda@farend.jp>2021-06-24 13:55:06 +0000
commit890dc20ad749f1f9fa0fca41a2c23bb520be5008 (patch)
treed006c63efe13a46e1254359aa2208f392de860f3 /app/controllers
parentf75756e870fb3ae5d0c793032472391bb573c9cd (diff)
downloadredmine-890dc20ad749f1f9fa0fca41a2c23bb520be5008.tar.gz
redmine-890dc20ad749f1f9fa0fca41a2c23bb520be5008.zip
API to archive/unarchive projects (#35420).
Patch by Felix Schäfer. git-svn-id: http://svn.redmine.org/redmine/trunk@21044 e93f8b46-1217-0410-a6f0-8f06a7374b81
Diffstat (limited to 'app/controllers')
-rw-r--r--app/controllers/projects_controller.rb23
1 files changed, 19 insertions, 4 deletions
diff --git a/app/controllers/projects_controller.rb b/app/controllers/projects_controller.rb
index a2624031b..673c77316 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
+ accept_api_auth :index, :show, :create, :update, :destroy, :archive, :unarchive
require_sudo_mode :destroy
helper :custom_fields
@@ -233,16 +233,31 @@ class ProjectsController < ApplicationController
def archive
unless @project.archive
- flash[:error] = l(:error_can_not_archive_project)
+ error = l(:error_can_not_archive_project)
+ end
+ respond_to do |format|
+ format.html do
+ flash[:error] = error if error
+ redirect_to_referer_or admin_projects_path(:status => params[:status])
+ end
+ format.api do
+ if error
+ render_api_errors error
+ else
+ render_api_ok
+ end
+ end
end
- redirect_to_referer_or admin_projects_path(:status => params[:status])
end
def unarchive
unless @project.active?
@project.unarchive
end
- redirect_to_referer_or admin_projects_path(:status => params[:status])
+ respond_to do |format|
+ format.html{ redirect_to_referer_or admin_projects_path(:status => params[:status]) }
+ format.api{ render_api_ok }
+ end
end
def bookmark