summaryrefslogtreecommitdiffstats
path: root/app
diff options
context:
space:
mode:
authorGo MAEDA <maeda@farend.jp>2019-09-09 08:55:43 +0000
committerGo MAEDA <maeda@farend.jp>2019-09-09 08:55:43 +0000
commit3ca75647dfbc3c41f11f202b436a1463cca8236c (patch)
tree115e02908886644aaa31d5f593141ce0c90f15bc /app
parentc22469838d33250a1615352accaa0ff9d4e59d04 (diff)
downloadredmine-3ca75647dfbc3c41f11f202b436a1463cca8236c.tar.gz
redmine-3ca75647dfbc3c41f11f202b436a1463cca8236c.zip
REST API for retrieving news (#13468).
Patch by Takenori TAKAKI. git-svn-id: http://svn.redmine.org/redmine/trunk@18441 e93f8b46-1217-0410-a6f0-8f06a7374b81
Diffstat (limited to 'app')
-rw-r--r--app/controllers/news_controller.rb2
-rw-r--r--app/views/news/show.api.rsb24
2 files changed, 25 insertions, 1 deletions
diff --git a/app/controllers/news_controller.rb b/app/controllers/news_controller.rb
index ed4db3b1b..6c1e7f1bd 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, :create
+ accept_api_auth :index, :show, :create
helper :watchers
helper :attachments
diff --git a/app/views/news/show.api.rsb b/app/views/news/show.api.rsb
new file mode 100644
index 000000000..0dd3a3b78
--- /dev/null
+++ b/app/views/news/show.api.rsb
@@ -0,0 +1,24 @@
+api.news do
+ api.id @news.id
+ api.project(:id => @news.project_id, :name => @news.project.name) unless @news.project.nil?
+ api.author(:id => @news.author_id, :name => @news.author.name) unless @news.author.nil?
+ api.title @news.title
+ api.summary @news.summary unless @news.summary.blank?
+ api.description @news.description
+ api.created_on @news.created_on
+
+ api.array :attachments do
+ @news.attachments.each do |attachment|
+ render_api_attachment(attachment, api)
+ end
+ end if include_in_api_response?('attachments')
+
+ api.array :comments do
+ @comments.each do |comment|
+ api.comment :id => comment.id do
+ api.author(:id => comment.author_id, :name => comment.author.name) unless comment.author.nil?
+ api.content comment.content
+ end
+ end
+ end if include_in_api_response?('comments')
+end