2013-02-05 14:16:51 -05:00
|
|
|
class AdminDetailedUserSerializer < AdminUserSerializer
|
|
|
|
|
|
|
|
attributes :moderator,
|
2013-02-07 10:45:24 -05:00
|
|
|
:can_grant_admin,
|
2013-02-05 14:16:51 -05:00
|
|
|
:can_revoke_admin,
|
2013-02-12 17:58:08 -05:00
|
|
|
:can_grant_moderation,
|
|
|
|
:can_revoke_moderation,
|
|
|
|
:can_impersonate,
|
2013-02-05 14:16:51 -05:00
|
|
|
:like_count,
|
2014-08-22 15:23:10 -04:00
|
|
|
:like_given_count,
|
2013-02-05 14:16:51 -05:00
|
|
|
:post_count,
|
2013-07-26 15:40:08 -04:00
|
|
|
:topic_count,
|
2013-02-05 14:16:51 -05:00
|
|
|
:flags_given_count,
|
|
|
|
:flags_received_count,
|
2013-02-07 02:11:56 -05:00
|
|
|
:private_topics_count,
|
2013-07-26 15:40:08 -04:00
|
|
|
:can_delete_all_posts,
|
2013-11-01 10:47:03 -04:00
|
|
|
:can_be_deleted,
|
2015-03-06 16:44:54 -05:00
|
|
|
:can_be_anonymized,
|
2014-02-10 16:59:36 -05:00
|
|
|
:suspend_reason,
|
2014-04-16 06:22:21 -04:00
|
|
|
:primary_group_id,
|
2014-09-08 11:11:56 -04:00
|
|
|
:badge_count,
|
2014-09-26 14:48:34 -04:00
|
|
|
:warnings_received_count,
|
2016-05-06 13:34:33 -04:00
|
|
|
:user_fields,
|
|
|
|
:bounce_score,
|
2017-02-21 07:45:30 -05:00
|
|
|
:reset_bounce_score_after,
|
|
|
|
:can_view_action_logs
|
2013-02-05 14:16:51 -05:00
|
|
|
|
|
|
|
has_one :approved_by, serializer: BasicUserSerializer, embed: :objects
|
2013-10-22 15:53:08 -04:00
|
|
|
has_one :api_key, serializer: ApiKeySerializer, embed: :objects
|
2013-11-07 13:53:32 -05:00
|
|
|
has_one :suspended_by, serializer: BasicUserSerializer, embed: :objects
|
2014-09-24 20:19:26 -04:00
|
|
|
has_one :tl3_requirements, serializer: TrustLevel3RequirementsSerializer, embed: :objects
|
2014-07-13 14:11:38 -04:00
|
|
|
has_many :groups, embed: :object, serializer: BasicGroupSerializer
|
2013-02-05 14:16:51 -05:00
|
|
|
|
|
|
|
def can_revoke_admin
|
|
|
|
scope.can_revoke_admin?(object)
|
|
|
|
end
|
|
|
|
|
|
|
|
def can_grant_admin
|
|
|
|
scope.can_grant_admin?(object)
|
|
|
|
end
|
2013-02-07 10:45:24 -05:00
|
|
|
|
2013-02-12 17:58:08 -05:00
|
|
|
def can_revoke_moderation
|
|
|
|
scope.can_revoke_moderation?(object)
|
|
|
|
end
|
|
|
|
|
|
|
|
def can_grant_moderation
|
|
|
|
scope.can_grant_moderation?(object)
|
|
|
|
end
|
|
|
|
|
2013-02-07 02:11:56 -05:00
|
|
|
def can_delete_all_posts
|
|
|
|
scope.can_delete_all_posts?(object)
|
|
|
|
end
|
2013-02-05 14:16:51 -05:00
|
|
|
|
2013-07-26 15:40:08 -04:00
|
|
|
def can_be_deleted
|
|
|
|
scope.can_delete_user?(object)
|
|
|
|
end
|
|
|
|
|
2015-03-06 16:44:54 -05:00
|
|
|
def can_be_anonymized
|
|
|
|
scope.can_anonymize_user?(object)
|
|
|
|
end
|
|
|
|
|
2013-07-26 15:40:08 -04:00
|
|
|
def topic_count
|
|
|
|
object.topics.count
|
|
|
|
end
|
|
|
|
|
2013-10-22 15:53:08 -04:00
|
|
|
def include_api_key?
|
2015-10-14 15:40:23 -04:00
|
|
|
scope.is_admin? && api_key.present?
|
2013-10-22 15:53:08 -04:00
|
|
|
end
|
|
|
|
|
2013-11-07 13:53:32 -05:00
|
|
|
def suspended_by
|
|
|
|
object.suspend_record.try(:acting_user)
|
2013-11-01 10:47:03 -04:00
|
|
|
end
|
|
|
|
|
2014-09-24 20:19:26 -04:00
|
|
|
def include_tl3_requirements?
|
2014-09-05 01:20:39 -04:00
|
|
|
object.has_trust_level?(TrustLevel[2])
|
2014-01-22 17:09:56 -05:00
|
|
|
end
|
|
|
|
|
2014-09-26 14:48:34 -04:00
|
|
|
def include_user_fields?
|
|
|
|
object.user_fields.present?
|
|
|
|
end
|
|
|
|
|
2016-05-06 13:34:33 -04:00
|
|
|
def bounce_score
|
|
|
|
object.user_stat.bounce_score
|
|
|
|
end
|
|
|
|
|
|
|
|
def reset_bounce_score_after
|
|
|
|
object.user_stat.reset_bounce_score_after
|
|
|
|
end
|
|
|
|
|
2017-02-21 07:45:30 -05:00
|
|
|
def can_view_action_logs
|
|
|
|
scope.can_view_action_logs?(object)
|
|
|
|
end
|
|
|
|
|
2013-02-05 14:16:51 -05:00
|
|
|
end
|