2019-05-02 18:17:27 -04:00
|
|
|
# frozen_string_literal: true
|
|
|
|
|
2013-03-14 14:45:29 -04:00
|
|
|
class SuggestedTopicSerializer < ListableTopicSerializer
|
2018-02-13 15:46:25 -05:00
|
|
|
include TopicTagsMixin
|
2013-02-05 14:16:51 -05:00
|
|
|
|
2016-02-03 02:50:05 -05:00
|
|
|
# need to embed so we have users
|
|
|
|
# front page json gets away without embedding
|
|
|
|
class SuggestedPosterSerializer < ApplicationSerializer
|
|
|
|
attributes :extras, :description
|
|
|
|
has_one :user, serializer: BasicUserSerializer, embed: :objects
|
|
|
|
end
|
|
|
|
|
2018-02-13 15:46:25 -05:00
|
|
|
attributes :archetype,
|
|
|
|
:like_count,
|
|
|
|
:views,
|
|
|
|
:category_id,
|
|
|
|
:featured_link,
|
|
|
|
:featured_link_root_domain
|
2016-02-03 02:50:05 -05:00
|
|
|
has_many :posters, serializer: SuggestedPosterSerializer, embed: :objects
|
|
|
|
|
|
|
|
def posters
|
|
|
|
object.posters || []
|
|
|
|
end
|
2016-07-05 15:00:09 -04:00
|
|
|
|
2016-12-05 07:31:43 -05:00
|
|
|
def include_featured_link?
|
|
|
|
SiteSetting.topic_featured_link_enabled
|
|
|
|
end
|
|
|
|
|
|
|
|
def featured_link
|
|
|
|
object.featured_link
|
|
|
|
end
|
2018-01-25 14:39:55 -05:00
|
|
|
|
|
|
|
def include_featured_link_root_domain?
|
|
|
|
SiteSetting.topic_featured_link_enabled && object.featured_link
|
|
|
|
end
|
2013-02-05 14:16:51 -05:00
|
|
|
end
|