2013-03-07 04:17:07 +08:00
|
|
|
require_dependency 'pinned_check'
|
|
|
|
|
2013-03-15 02:45:29 +08:00
|
|
|
class TopicListItemSerializer < ListableTopicSerializer
|
2013-02-06 03:16:51 +08:00
|
|
|
|
2013-02-26 00:42:20 +08:00
|
|
|
attributes :views,
|
|
|
|
:like_count,
|
|
|
|
:visible,
|
|
|
|
:pinned,
|
|
|
|
:closed,
|
|
|
|
:archived,
|
|
|
|
:starred,
|
|
|
|
:has_best_of,
|
2013-03-15 02:45:29 +08:00
|
|
|
:archetype
|
2013-02-06 03:16:51 +08:00
|
|
|
|
|
|
|
has_one :category
|
|
|
|
has_many :posters, serializer: TopicPosterSerializer, embed: :objects
|
|
|
|
|
|
|
|
def starred
|
|
|
|
object.user_data.starred?
|
|
|
|
end
|
|
|
|
alias :include_starred? :seen
|
|
|
|
|
|
|
|
def posters
|
|
|
|
object.posters || []
|
|
|
|
end
|
|
|
|
|
2013-03-07 04:17:07 +08:00
|
|
|
def pinned
|
|
|
|
PinnedCheck.new(object, object.user_data).pinned?
|
|
|
|
end
|
|
|
|
|
2013-02-06 03:16:51 +08:00
|
|
|
end
|