2019-05-02 18:17:27 -04:00
|
|
|
# frozen_string_literal: true
|
|
|
|
|
2013-02-05 14:16:51 -05:00
|
|
|
class InviteSerializer < ApplicationSerializer
|
2021-03-03 04:45:29 -05:00
|
|
|
attributes :id,
|
2021-03-18 13:05:38 -04:00
|
|
|
:invite_key,
|
2021-03-03 04:45:29 -05:00
|
|
|
:link,
|
|
|
|
:email,
|
2021-12-08 10:06:57 -05:00
|
|
|
:domain,
|
2021-03-09 09:56:18 -05:00
|
|
|
:emailed,
|
2021-03-03 04:45:29 -05:00
|
|
|
:max_redemptions_allowed,
|
2021-03-11 11:19:32 -05:00
|
|
|
:redemption_count,
|
2021-03-03 04:45:29 -05:00
|
|
|
:custom_message,
|
2021-03-11 11:19:32 -05:00
|
|
|
:created_at,
|
2021-03-03 04:45:29 -05:00
|
|
|
:updated_at,
|
|
|
|
:expires_at,
|
2022-02-16 11:35:02 -05:00
|
|
|
:expired
|
2021-03-03 04:45:29 -05:00
|
|
|
|
|
|
|
has_many :topics, embed: :object, serializer: BasicTopicSerializer
|
|
|
|
has_many :groups, embed: :object, serializer: BasicGroupSerializer
|
2013-02-05 14:16:51 -05:00
|
|
|
|
|
|
|
def include_email?
|
2020-03-04 11:47:09 -05:00
|
|
|
options[:show_emails] && !object.redeemed?
|
2013-02-05 14:16:51 -05:00
|
|
|
end
|
|
|
|
|
2021-03-09 09:56:18 -05:00
|
|
|
def include_emailed?
|
|
|
|
email.present?
|
|
|
|
end
|
|
|
|
|
|
|
|
def emailed
|
|
|
|
object.emailed_status != Invite.emailed_status_types[:not_required]
|
|
|
|
end
|
|
|
|
|
2021-03-11 11:19:32 -05:00
|
|
|
def include_custom_message?
|
|
|
|
email.present?
|
|
|
|
end
|
|
|
|
|
|
|
|
def include_max_redemptions_allowed?
|
|
|
|
email.blank?
|
|
|
|
end
|
|
|
|
|
|
|
|
def include_redemption_count?
|
|
|
|
email.blank?
|
|
|
|
end
|
|
|
|
|
2014-01-21 15:13:55 -05:00
|
|
|
def expired
|
|
|
|
object.expired?
|
|
|
|
end
|
2013-02-05 14:16:51 -05:00
|
|
|
end
|