diff options
author | Go MAEDA <maeda@farend.jp> | 2019-09-09 09:03:41 +0000 |
---|---|---|
committer | Go MAEDA <maeda@farend.jp> | 2019-09-09 09:03:41 +0000 |
commit | 89739876d170875e1e12d84bfb1b43f342daf818 (patch) | |
tree | 47c7819106bd1ea7b2350b6995110b8aae4423f0 /app | |
parent | 780e64a100d620574b0afa3cd8317dc4255344ad (diff) | |
download | redmine-89739876d170875e1e12d84bfb1b43f342daf818.tar.gz redmine-89739876d170875e1e12d84bfb1b43f342daf818.zip |
REST API for updating news (#13468).
Patch by Takenori TAKAKI.
git-svn-id: http://svn.redmine.org/redmine/trunk@18443 e93f8b46-1217-0410-a6f0-8f06a7374b81
Diffstat (limited to 'app')
-rw-r--r-- | app/controllers/news_controller.rb | 20 |
1 files changed, 14 insertions, 6 deletions
diff --git a/app/controllers/news_controller.rb b/app/controllers/news_controller.rb index 3ea0abea7..5d63f449a 100644 --- a/app/controllers/news_controller.rb +++ b/app/controllers/news_controller.rb @@ -26,7 +26,7 @@ class NewsController < ApplicationController before_action :authorize, :except => [:index] before_action :find_optional_project, :only => :index accept_rss_auth :index - accept_api_auth :index, :show, :create, :destroy + accept_api_auth :index, :show, :create, :update, :destroy helper :watchers helper :attachments @@ -94,13 +94,21 @@ class NewsController < ApplicationController def update @news.safe_attributes = params[:news] - @news.save_attachments(params[:attachments]) + @news.save_attachments(params[:attachments] || (params[:news] && params[:news][:uploads])) if @news.save - render_attachment_warning_if_needed(@news) - flash[:notice] = l(:notice_successful_update) - redirect_to news_path(@news) + respond_to do |format| + format.html { + render_attachment_warning_if_needed(@news) + flash[:notice] = l(:notice_successful_update) + redirect_to news_path(@news) + } + format.api { render_api_ok } + end else - render :action => 'edit' + respond_to do |format| + format.html { render :action => 'edit' } + format.api { render_validation_errors(@news) } + end end end |