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,
|
||||
root: 'latest_posts',
|
||||
add_raw: true,
|
||||
add_title: true,
|
||||
all_post_actions: counts)
|
||||
)
|
||||
end
|
||||
|
|
|
@ -5,6 +5,7 @@ class PostSerializer < BasicPostSerializer
|
|||
:topic_view,
|
||||
:parent_post,
|
||||
:add_raw,
|
||||
:add_title,
|
||||
:single_post_link_counts,
|
||||
:draft_sequence,
|
||||
:post_actions,
|
||||
|
@ -28,6 +29,9 @@ class PostSerializer < BasicPostSerializer
|
|||
:yours,
|
||||
:topic_id,
|
||||
:topic_slug,
|
||||
:topic_title,
|
||||
:topic_html_title,
|
||||
:category_id,
|
||||
:display_username,
|
||||
:primary_group_name,
|
||||
:version,
|
||||
|
@ -73,6 +77,30 @@ class PostSerializer < BasicPostSerializer
|
|||
object.try(:topic).try(:slug)
|
||||
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?
|
||||
!!(object.try(:user).try(:moderator?))
|
||||
end
|
||||
|
|
Loading…
Reference in New Issue