2019-05-02 17:17:27 -05:00
|
|
|
# frozen_string_literal: true
|
|
|
|
|
2014-07-28 12:17:37 -05:00
|
|
|
class FlaggedUserSerializer < BasicUserSerializer
|
|
|
|
attributes :can_delete_all_posts,
|
|
|
|
:can_be_deleted,
|
|
|
|
:post_count,
|
|
|
|
:topic_count,
|
2018-06-13 10:44:13 -05:00
|
|
|
:ip_address,
|
2018-10-31 14:35:07 -05:00
|
|
|
:custom_fields,
|
|
|
|
:flags_agreed,
|
|
|
|
:flags_disagreed,
|
|
|
|
:flags_ignored
|
2014-07-28 12:17:37 -05: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-10-31 14:35:07 -05: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 10:44:13 -05:00
|
|
|
def custom_fields
|
|
|
|
fields = User.whitelisted_user_custom_fields(scope)
|
|
|
|
|
2018-06-14 08:22:42 -05:00
|
|
|
result = {}
|
|
|
|
fields.each do |k|
|
|
|
|
result[k] = object.custom_fields[k] if object.custom_fields[k].present?
|
2018-06-13 10:44:13 -05:00
|
|
|
end
|
|
|
|
|
2018-06-14 08:22:42 -05:00
|
|
|
result
|
2018-06-13 10:44:13 -05:00
|
|
|
end
|
|
|
|
|
2014-07-28 12:17:37 -05:00
|
|
|
end
|