mirror of
https://github.com/discourse/discourse.git
synced 2025-02-25 18:55:32 -06:00
FEATURE: Include topic title, category in posts.json
This commit is contained in:
parent
0a46ec9c50
commit
32e5016dbb
@ -58,6 +58,7 @@ class PostsController < ApplicationController
|
|||||||
scope: guardian,
|
scope: guardian,
|
||||||
root: 'latest_posts',
|
root: 'latest_posts',
|
||||||
add_raw: true,
|
add_raw: true,
|
||||||
|
add_title: true,
|
||||||
all_post_actions: counts)
|
all_post_actions: counts)
|
||||||
)
|
)
|
||||||
end
|
end
|
||||||
|
@ -5,6 +5,7 @@ class PostSerializer < BasicPostSerializer
|
|||||||
:topic_view,
|
:topic_view,
|
||||||
:parent_post,
|
:parent_post,
|
||||||
:add_raw,
|
:add_raw,
|
||||||
|
:add_title,
|
||||||
:single_post_link_counts,
|
:single_post_link_counts,
|
||||||
:draft_sequence,
|
:draft_sequence,
|
||||||
:post_actions,
|
:post_actions,
|
||||||
@ -28,6 +29,9 @@ class PostSerializer < BasicPostSerializer
|
|||||||
:yours,
|
:yours,
|
||||||
:topic_id,
|
:topic_id,
|
||||||
:topic_slug,
|
:topic_slug,
|
||||||
|
:topic_title,
|
||||||
|
:topic_html_title,
|
||||||
|
:category_id,
|
||||||
:display_username,
|
:display_username,
|
||||||
:primary_group_name,
|
:primary_group_name,
|
||||||
:version,
|
:version,
|
||||||
@ -73,6 +77,30 @@ class PostSerializer < BasicPostSerializer
|
|||||||
object.try(:topic).try(:slug)
|
object.try(:topic).try(:slug)
|
||||||
end
|
end
|
||||||
|
|
||||||
|
def include_topic_title?
|
||||||
|
@add_title
|
||||||
|
end
|
||||||
|
|
||||||
|
def include_topic_html_title?
|
||||||
|
@add_title
|
||||||
|
end
|
||||||
|
|
||||||
|
def include_category_id?
|
||||||
|
@add_title
|
||||||
|
end
|
||||||
|
|
||||||
|
def topic_title
|
||||||
|
object.topic.title
|
||||||
|
end
|
||||||
|
|
||||||
|
def topic_html_title
|
||||||
|
object.topic.fancy_title
|
||||||
|
end
|
||||||
|
|
||||||
|
def category_id
|
||||||
|
object.topic.category_id
|
||||||
|
end
|
||||||
|
|
||||||
def moderator?
|
def moderator?
|
||||||
!!(object.try(:user).try(:moderator?))
|
!!(object.try(:user).try(:moderator?))
|
||||||
end
|
end
|
||||||
|
Loading…
Reference in New Issue
Block a user