2014-03-05 07:52:20 -05:00
|
|
|
class UserBadgeSerializer < ApplicationSerializer
|
2016-01-18 01:59:07 -05:00
|
|
|
|
|
|
|
class UserSerializer < BasicUserSerializer
|
2018-12-06 06:18:52 -05:00
|
|
|
include UserPrimaryGroupMixin
|
|
|
|
|
|
|
|
attributes :name,
|
|
|
|
:moderator,
|
|
|
|
:admin
|
2016-01-18 01:59:07 -05:00
|
|
|
end
|
|
|
|
|
2014-07-01 08:00:31 -04:00
|
|
|
attributes :id, :granted_at, :count, :post_id, :post_number
|
2014-03-05 07:52:20 -05:00
|
|
|
|
|
|
|
has_one :badge
|
2016-01-18 01:59:07 -05:00
|
|
|
has_one :user, serializer: UserSerializer, root: :users
|
|
|
|
has_one :granted_by, serializer: UserSerializer, root: :users
|
2014-06-27 15:08:03 -04:00
|
|
|
has_one :topic, serializer: BasicTopicSerializer
|
2014-05-21 03:22:42 -04:00
|
|
|
|
|
|
|
def include_count?
|
|
|
|
object.respond_to? :count
|
|
|
|
end
|
2014-06-27 15:08:03 -04:00
|
|
|
|
|
|
|
def include_post_id?
|
2014-07-22 21:42:24 -04:00
|
|
|
object.badge.show_posts && object.post_id && object.post
|
2014-06-27 15:08:03 -04:00
|
|
|
end
|
2014-07-01 08:00:31 -04:00
|
|
|
|
2014-06-27 15:08:03 -04:00
|
|
|
alias :include_topic? :include_post_id?
|
2014-07-22 21:42:24 -04:00
|
|
|
alias :include_post_number? :include_post_id?
|
2014-06-27 15:08:03 -04:00
|
|
|
|
2014-07-01 08:00:31 -04:00
|
|
|
def post_number
|
|
|
|
object.post && object.post.post_number
|
|
|
|
end
|
|
|
|
|
2014-06-27 15:08:03 -04:00
|
|
|
def topic
|
|
|
|
object.post.topic
|
|
|
|
end
|
2014-03-05 07:52:20 -05:00
|
|
|
end
|