discourse/app/serializers/user_badge_serializer.rb

22 lines
499 B
Ruby
Raw Normal View History

2014-03-05 07:52:20 -05:00
class UserBadgeSerializer < ApplicationSerializer
attributes :id, :granted_at, :count, :post_id
2014-03-05 07:52:20 -05:00
has_one :badge
2014-04-17 12:27:42 -04:00
has_one :user, serializer: BasicUserSerializer, root: :users
2014-03-05 07:52:20 -05:00
has_one :granted_by, serializer: BasicUserSerializer, root: :users
has_one :topic, serializer: BasicTopicSerializer
2014-05-21 03:22:42 -04:00
def include_count?
object.respond_to? :count
end
def include_post_id?
!object.post_id.nil?
end
alias :include_topic? :include_post_id?
def topic
object.post.topic
end
2014-03-05 07:52:20 -05:00
end