2019-05-03 06:17:27 +08:00
|
|
|
# frozen_string_literal: true
|
|
|
|
|
2019-01-04 01:03:01 +08:00
|
|
|
class ReviewableUserSerializer < ReviewableSerializer
|
2021-01-15 06:43:26 +08:00
|
|
|
attributes :link_admin, :user_fields, :reject_reason
|
2019-04-04 05:07:24 +08:00
|
|
|
|
2019-04-04 04:41:04 +08:00
|
|
|
payload_attributes(:username, :email, :name, :bio, :website)
|
2019-01-04 01:03:01 +08:00
|
|
|
|
2019-04-04 05:07:24 +08:00
|
|
|
def link_admin
|
|
|
|
scope.is_staff? && object.target.present?
|
|
|
|
end
|
|
|
|
|
2019-04-05 02:45:04 +08:00
|
|
|
def user_fields
|
|
|
|
object.target.user_fields
|
|
|
|
end
|
|
|
|
|
|
|
|
def include_user_fields?
|
|
|
|
object.target.present? && object.target.user_fields.present?
|
|
|
|
end
|
2024-05-31 01:30:06 +08: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-04 01:03:01 +08:00
|
|
|
end
|