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