2019-05-02 18:17:27 -04:00
|
|
|
# frozen_string_literal: true
|
|
|
|
|
2019-01-03 12:03:01 -05:00
|
|
|
class ReviewableUserSerializer < ReviewableSerializer
|
2021-01-14 17:43:26 -05:00
|
|
|
attributes :link_admin, :user_fields, :reject_reason
|
2019-04-03 17:07:24 -04:00
|
|
|
|
2019-04-03 16:41:04 -04:00
|
|
|
payload_attributes(:username, :email, :name, :bio, :website)
|
2019-01-03 12:03:01 -05:00
|
|
|
|
2019-04-03 17:07:24 -04:00
|
|
|
def link_admin
|
|
|
|
scope.is_staff? && object.target.present?
|
|
|
|
end
|
|
|
|
|
2019-04-04 14:45:04 -04:00
|
|
|
def user_fields
|
|
|
|
object.target.user_fields
|
|
|
|
end
|
|
|
|
|
|
|
|
def include_user_fields?
|
|
|
|
object.target.present? && object.target.user_fields.present?
|
|
|
|
end
|
2024-05-30 13:30:06 -04:00
|
|
|
|
|
|
|
def attributes(*args)
|
|
|
|
data = super
|
|
|
|
data[:payload]&.delete("email") if !include_email?
|
|
|
|
data
|
|
|
|
end
|
|
|
|
|
|
|
|
def include_email?
|
|
|
|
scope.can_check_emails?(scope.user)
|
|
|
|
end
|
2019-01-03 12:03:01 -05:00
|
|
|
end
|