2016-01-19 23:11:52 -05:00
|
|
|
class UserSummarySerializer < ApplicationSerializer
|
2016-04-20 16:58:30 -04:00
|
|
|
|
|
|
|
class TopicSerializer < ApplicationSerializer
|
|
|
|
attributes :id, :created_at, :fancy_title, :slug, :like_count
|
2016-01-19 23:11:52 -05:00
|
|
|
end
|
|
|
|
|
|
|
|
class ReplySerializer < ApplicationSerializer
|
|
|
|
attributes :post_number, :like_count, :created_at
|
|
|
|
has_one :topic, serializer: TopicSerializer
|
|
|
|
end
|
|
|
|
|
2016-04-13 17:02:51 -04:00
|
|
|
class LinkSerializer < ApplicationSerializer
|
2016-04-20 16:58:30 -04:00
|
|
|
attributes :url, :title, :clicks, :post_number
|
|
|
|
has_one :topic, serializer: TopicSerializer
|
|
|
|
|
|
|
|
def post_number
|
|
|
|
object.post.post_number
|
|
|
|
end
|
2016-04-13 17:02:51 -04:00
|
|
|
end
|
|
|
|
|
|
|
|
class MostLikedByUserSerializer < BasicUserSerializer
|
|
|
|
attributes :likes, :name
|
|
|
|
end
|
|
|
|
|
2016-01-19 23:11:52 -05:00
|
|
|
has_many :topics, serializer: TopicSerializer
|
|
|
|
has_many :replies, serializer: ReplySerializer, embed: :object
|
2016-04-13 17:02:51 -04:00
|
|
|
has_many :links, serializer: LinkSerializer, embed: :object
|
|
|
|
has_many :most_liked_by_users, serializer: MostLikedByUserSerializer, embed: :object
|
2016-04-20 16:58:30 -04:00
|
|
|
has_many :badges, serializer: UserBadgeSerializer, embed: :object
|
2016-01-19 23:11:52 -05:00
|
|
|
|
2016-03-30 12:05:16 -04:00
|
|
|
attributes :likes_given,
|
|
|
|
:likes_received,
|
|
|
|
:posts_read_count,
|
|
|
|
:days_visited,
|
|
|
|
:topic_count,
|
|
|
|
:post_count,
|
2016-04-13 17:02:51 -04:00
|
|
|
:time_read,
|
|
|
|
:bookmark_count
|
2016-03-29 02:11:47 -04:00
|
|
|
|
|
|
|
def include_badges?
|
|
|
|
SiteSetting.enable_badges
|
|
|
|
end
|
2016-03-30 12:05:16 -04:00
|
|
|
|
|
|
|
def time_read
|
|
|
|
AgeWords.age_words(object.time_read)
|
|
|
|
end
|
2016-01-19 23:11:52 -05:00
|
|
|
end
|