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