2013-03-06 15:17:07 -05:00
|
|
|
require_dependency 'pinned_check'
|
|
|
|
|
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,
|
|
|
|
:visible,
|
|
|
|
:pinned,
|
|
|
|
:closed,
|
|
|
|
:archived,
|
|
|
|
:last_post_age,
|
|
|
|
:starred,
|
|
|
|
:has_best_of,
|
2013-03-14 14:45:29 -04:00
|
|
|
:archetype
|
2013-02-05 14:16:51 -05:00
|
|
|
|
|
|
|
has_one :category
|
|
|
|
has_many :posters, serializer: TopicPosterSerializer, embed: :objects
|
|
|
|
|
|
|
|
def last_post_age
|
|
|
|
return nil if object.last_posted_at.blank?
|
|
|
|
AgeWords.age_words(Time.now - object.last_posted_at)
|
|
|
|
end
|
|
|
|
|
|
|
|
def starred
|
|
|
|
object.user_data.starred?
|
|
|
|
end
|
|
|
|
alias :include_starred? :seen
|
|
|
|
|
|
|
|
def posters
|
|
|
|
object.posters || []
|
|
|
|
end
|
|
|
|
|
2013-03-06 15:17:07 -05:00
|
|
|
def pinned
|
|
|
|
PinnedCheck.new(object, object.user_data).pinned?
|
|
|
|
end
|
|
|
|
|
2013-02-05 14:16:51 -05:00
|
|
|
end
|