2013-03-14 14:45:29 -04:00
|
|
|
class TopicListItemSerializer < ListableTopicSerializer
|
2013-02-05 14:16:51 -05:00
|
|
|
|
2013-02-25 11:42:20 -05:00
|
|
|
attributes :views,
|
|
|
|
:like_count,
|
|
|
|
:starred,
|
2013-11-18 12:48:26 -05:00
|
|
|
:has_summary,
|
2013-04-02 16:52:51 -04:00
|
|
|
:archetype,
|
2013-10-23 14:40:39 -04:00
|
|
|
:last_poster_username,
|
|
|
|
:category_id
|
2013-02-05 14:16:51 -05:00
|
|
|
|
|
|
|
has_many :posters, serializer: TopicPosterSerializer, embed: :objects
|
|
|
|
|
|
|
|
def starred
|
|
|
|
object.user_data.starred?
|
|
|
|
end
|
|
|
|
alias :include_starred? :seen
|
|
|
|
|
|
|
|
def posters
|
|
|
|
object.posters || []
|
|
|
|
end
|
|
|
|
|
2013-09-19 16:25:25 -04:00
|
|
|
def last_poster_username
|
|
|
|
object.posters.find { |poster| poster.user.id == object.last_post_user_id }.try(:user).try(:username)
|
|
|
|
end
|
|
|
|
|
2013-02-05 14:16:51 -05:00
|
|
|
end
|