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