2020-04-07 23:58:49 +08:00
|
|
|
# frozen_string_literal: true
|
|
|
|
|
|
|
|
class InvitedSerializer < ApplicationSerializer
|
2021-03-03 17:45:29 +08:00
|
|
|
attributes :invites, :can_see_invite_details, :counts
|
2020-04-07 23:58:49 +08:00
|
|
|
|
|
|
|
def invites
|
|
|
|
ActiveModel::ArraySerializer.new(
|
|
|
|
object.invite_list,
|
2021-03-06 19:29:35 +08:00
|
|
|
each_serializer: object.type == "pending" || object.type == "expired" ? InviteSerializer : InvitedUserSerializer,
|
2020-04-07 23:58:49 +08:00
|
|
|
scope: scope,
|
|
|
|
root: false,
|
|
|
|
show_emails: object.show_emails
|
|
|
|
).as_json
|
|
|
|
end
|
|
|
|
|
|
|
|
def can_see_invite_details
|
|
|
|
scope.can_see_invite_details?(object.inviter)
|
|
|
|
end
|
|
|
|
|
2021-03-03 17:45:29 +08:00
|
|
|
def counts
|
|
|
|
object.counts
|
2020-04-07 23:58:49 +08:00
|
|
|
end
|
|
|
|
end
|