2019-05-03 06:17:27 +08:00
|
|
|
# frozen_string_literal: true
|
|
|
|
|
2017-06-22 00:56:38 +08:00
|
|
|
require_relative "post_item_excerpt"
|
|
|
|
|
2014-02-07 23:44:03 +08:00
|
|
|
class GroupPostSerializer < ApplicationSerializer
|
2017-06-22 00:56:38 +08:00
|
|
|
include PostItemExcerpt
|
|
|
|
|
2014-02-07 23:44:03 +08:00
|
|
|
attributes :id, :created_at, :title, :url, :category_id, :post_number, :topic_id, :post_type
|
|
|
|
|
2016-12-05 18:46:23 +08:00
|
|
|
has_one :user, serializer: GroupPostUserSerializer, embed: :object
|
2016-12-05 18:12:24 +08:00
|
|
|
has_one :topic, serializer: BasicTopicSerializer, embed: :object
|
2014-02-07 23:44:03 +08:00
|
|
|
|
|
|
|
def title
|
|
|
|
object.topic.title
|
|
|
|
end
|
|
|
|
|
2014-02-13 03:23:10 +08:00
|
|
|
def include_user_long_name?
|
|
|
|
SiteSetting.enable_names?
|
|
|
|
end
|
2014-11-15 08:30:05 +08:00
|
|
|
|
2017-09-14 05:14:46 +08:00
|
|
|
def category_id
|
|
|
|
object.topic.category_id
|
2014-11-15 08:30:05 +08:00
|
|
|
end
|
2014-02-07 23:44:03 +08:00
|
|
|
end
|