discourse/app/serializers/group_post_serializer.rb

38 lines
627 B
Ruby
Raw Normal View History

class GroupPostSerializer < ApplicationSerializer
attributes :id,
:cooked,
:created_at,
:title,
:url,
:user_title,
:user_long_name,
2016-04-01 05:33:25 +08:00
:topic,
:category
has_one :user, serializer: BasicUserSerializer, embed: :objects
def title
object.topic.title
end
def user_long_name
object.user.try(:name)
end
def user_title
object.user.try(:title)
end
def include_user_long_name?
SiteSetting.enable_names?
end
2016-04-01 05:33:25 +08:00
def topic
object.topic
end
def category
object.topic.category
end
end