discourse/app/serializers/topic_list_item_serializer.rb
Sam 921dd75dd9 FIX: anonymous had <a> items for pin/unpin
FEATURE: display category in search results
FEATURE: display topic state (locked/pinned/etc) in search results

UI cleanup for search results, clearing floats and so on.
2014-09-03 12:13:26 +10:00

37 lines
795 B
Ruby

class TopicListItemSerializer < ListableTopicSerializer
attributes :views,
:like_count,
:starred,
:has_summary,
:archetype,
:last_poster_username,
:category_id
has_many :posters, serializer: TopicPosterSerializer, embed: :objects
has_many :participants, serializer: TopicPosterSerializer, embed: :objects
def starred
object.user_data.starred?
end
alias :include_starred? :has_user_data
def posters
object.posters || []
end
def last_poster_username
posters.find { |poster| poster.user.id == object.last_post_user_id }.try(:user).try(:username)
end
def participants
object.participants_summary || []
end
def include_participants?
object.private_message?
end
end