discourse/app/serializers/admin_detailed_user_seriali...

Failed to ignore revisions in .git-blame-ignore-revs.

125 lines
2.8 KiB
Ruby
Raw Normal View History

# frozen_string_literal: true
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,
:can_grant_moderation,
:can_revoke_moderation,
:can_impersonate,
2013-02-05 14:16:51 -05:00
:like_count,
:like_given_count,
2013-02-05 14:16:51 -05:00
:post_count,
:topic_count,
2013-02-05 14:16:51 -05:00
:flags_given_count,
:flags_received_count,
:private_topics_count,
:can_delete_all_posts,
:can_be_deleted,
:can_be_anonymized,
:full_suspend_reason,
:suspended_till,
:silence_reason,
:primary_group_id,
:badge_count,
:warnings_received_count,
:user_fields,
:bounce_score,
:reset_bounce_score_after,
:can_view_action_logs,
:second_factor_enabled,
:can_disable_second_factor,
:api_key_count
2013-02-05 14:16:51 -05:00
has_one :approved_by, serializer: BasicUserSerializer, embed: :objects
has_one :suspended_by, serializer: BasicUserSerializer, embed: :objects
has_one :silenced_by, serializer: BasicUserSerializer, embed: :objects
2014-09-24 20:19:26 -04:00
has_one :tl3_requirements, serializer: TrustLevel3RequirementsSerializer, embed: :objects
has_many :groups, embed: :object, serializer: BasicGroupSerializer
2013-02-05 14:16:51 -05:00
def second_factor_enabled
object.totp_enabled? || object.security_keys_enabled?
end
def can_disable_second_factor
object&.id != scope.user.id
end
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
def can_revoke_moderation
scope.can_revoke_moderation?(object)
end
def can_grant_moderation
scope.can_grant_moderation?(object)
end
def can_delete_all_posts
scope.can_delete_all_posts?(object)
end
2013-02-05 14:16:51 -05:00
def can_be_deleted
scope.can_delete_user?(object)
end
def can_be_anonymized
scope.can_anonymize_user?(object)
end
def topic_count
object.topics.count
end
2013-10-22 15:53:08 -04:00
def include_api_key?
scope.is_admin? && api_key.present?
2013-10-22 15:53:08 -04:00
end
def suspended_by
object.suspend_record.try(:acting_user)
end
def silence_reason
object.silence_reason
end
def silenced_by
object.silenced_record.try(:acting_user)
end
2014-09-24 20:19:26 -04:00
def include_tl3_requirements?
object.has_trust_level?(TrustLevel[2])
end
def include_user_fields?
object.user_fields.present?
end
def bounce_score
object.user_stat.bounce_score
end
def reset_bounce_score_after
object.user_stat.reset_bounce_score_after
end
def can_view_action_logs
scope.can_view_action_logs?(object)
end
def post_count
object.posts.count
end
def api_key_count
object.api_keys.active.count
end
2013-02-05 14:16:51 -05:00
end