2019-05-03 06:17:27 +08:00
|
|
|
# frozen_string_literal: true
|
|
|
|
|
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,
|
2018-11-01 03:35:07 +08:00
|
|
|
:custom_fields,
|
|
|
|
:flags_agreed,
|
|
|
|
:flags_disagreed,
|
|
|
|
:flags_ignored
|
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-11-01 03:35:07 +08:00
|
|
|
def flags_agreed
|
|
|
|
object.user_stat.flags_agreed
|
|
|
|
end
|
|
|
|
|
|
|
|
def flags_disagreed
|
|
|
|
object.user_stat.flags_disagreed
|
|
|
|
end
|
|
|
|
|
|
|
|
def flags_ignored
|
|
|
|
object.user_stat.flags_ignored
|
|
|
|
end
|
|
|
|
|
2018-06-13 23:44:13 +08:00
|
|
|
def custom_fields
|
2020-07-27 08:23:54 +08:00
|
|
|
fields = User.allowed_user_custom_fields(scope)
|
2018-06-13 23:44:13 +08:00
|
|
|
|
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
|