2019-05-03 06:17:27 +08:00
|
|
|
# frozen_string_literal: true
|
|
|
|
|
2014-11-27 02:56:12 +08:00
|
|
|
require_dependency 'admin_user_list_serializer'
|
2013-02-06 03:16:51 +08:00
|
|
|
|
2014-11-27 02:56:12 +08:00
|
|
|
class AdminUserSerializer < AdminUserListSerializer
|
|
|
|
|
2015-09-19 20:13:28 +08:00
|
|
|
attributes :name,
|
|
|
|
:associated_accounts,
|
2013-05-08 09:58:34 +08:00
|
|
|
:can_send_activation_email,
|
|
|
|
:can_activate,
|
2015-01-07 00:06:05 +08:00
|
|
|
:can_deactivate,
|
2019-04-09 23:07:04 +08:00
|
|
|
:can_approve,
|
2014-11-27 02:56:12 +08:00
|
|
|
:ip_address,
|
2017-07-04 16:29:05 +08:00
|
|
|
:registration_ip_address
|
2013-10-04 11:28:49 +08:00
|
|
|
|
2014-08-23 08:34:48 +08:00
|
|
|
has_one :single_sign_on_record, serializer: SingleSignOnRecordSerializer, embed: :objects
|
|
|
|
|
2019-04-09 23:07:04 +08:00
|
|
|
def can_approve
|
2019-04-17 02:42:47 +08:00
|
|
|
scope.can_approve?(object)
|
2019-04-09 23:07:04 +08:00
|
|
|
end
|
|
|
|
|
|
|
|
def include_can_approve?
|
|
|
|
SiteSetting.must_approve_users
|
|
|
|
end
|
|
|
|
|
2013-05-08 09:58:34 +08:00
|
|
|
def can_send_activation_email
|
|
|
|
scope.can_send_activation_email?(object)
|
|
|
|
end
|
|
|
|
|
|
|
|
def can_activate
|
|
|
|
scope.can_activate?(object)
|
|
|
|
end
|
|
|
|
|
|
|
|
def can_deactivate
|
|
|
|
scope.can_deactivate?(object)
|
|
|
|
end
|
|
|
|
|
2013-11-06 04:00:47 +08:00
|
|
|
def ip_address
|
|
|
|
object.ip_address.try(:to_s)
|
|
|
|
end
|
|
|
|
|
2014-04-30 02:37:56 +08:00
|
|
|
def registration_ip_address
|
|
|
|
object.registration_ip_address.try(:to_s)
|
|
|
|
end
|
|
|
|
|
2013-02-06 03:16:51 +08:00
|
|
|
end
|