2014-07-29 01:17:37 +08:00
|
|
|
class FlaggedUserSerializer < BasicUserSerializer
|
|
|
|
attributes :can_delete_all_posts,
|
|
|
|
:can_be_deleted,
|
|
|
|
:post_count,
|
|
|
|
:topic_count,
|
2018-06-13 23:44:13 +08:00
|
|
|
:ip_address,
|
|
|
|
:custom_fields
|
2014-07-29 01:17:37 +08:00
|
|
|
|
|
|
|
def can_delete_all_posts
|
|
|
|
scope.can_delete_all_posts?(object)
|
|
|
|
end
|
|
|
|
|
|
|
|
def can_be_deleted
|
|
|
|
scope.can_delete_user?(object)
|
|
|
|
end
|
|
|
|
|
|
|
|
def ip_address
|
|
|
|
object.ip_address.try(:to_s)
|
|
|
|
end
|
|
|
|
|
2018-06-13 23:44:13 +08:00
|
|
|
def custom_fields
|
|
|
|
fields = User.whitelisted_user_custom_fields(scope)
|
|
|
|
|
2018-06-14 21:22:42 +08:00
|
|
|
result = {}
|
|
|
|
fields.each do |k|
|
|
|
|
result[k] = object.custom_fields[k] if object.custom_fields[k].present?
|
2018-06-13 23:44:13 +08:00
|
|
|
end
|
|
|
|
|
2018-06-14 21:22:42 +08:00
|
|
|
result
|
2018-06-13 23:44:13 +08:00
|
|
|
end
|
|
|
|
|
2014-07-29 01:17:37 +08:00
|
|
|
end
|