2
0
Fork 0
mirror of https://github.com/discourse/discourse.git synced 2026-03-04 01:15:08 +08:00
discourse/app/serializers/admin_user_serializer.rb
Osama Sayegh 0bc18fdf78
FEATURE: Add site setting to prevent mods from changing trust levels (#35160)
This commit adds a new setting `moderators_change_trust_levels` to
control whether moderators are allowed to change trust level of users.
Moderators are currently allowed to change trust levels, so this new
setting is enabled by default to avoid sudden changes in behavior for
existing sites.

When the setting is disabled and moderators are not allowed to change
trust levels, they see the trust levels dropdown disabled.

Internal topic: t/141392.

---------

Co-authored-by: Alan Guo Xiang Tan <gxtan1990@gmail.com>
2025-10-03 13:19:24 +03:00

64 lines
1.2 KiB
Ruby

# frozen_string_literal: true
class AdminUserSerializer < AdminUserListSerializer
attributes :name,
:associated_accounts,
:can_send_activation_email,
:can_activate,
:can_deactivate,
:can_approve,
:can_change_trust_level,
:ip_address,
:registration_ip_address,
:include_ip
has_one :single_sign_on_record, serializer: SingleSignOnRecordSerializer, embed: :objects
def can_approve
scope.can_approve?(object)
end
def include_can_approve?
SiteSetting.must_approve_users
end
def can_send_activation_email
scope.can_send_activation_email?(object)
end
def can_activate
scope.can_activate?(object)
end
def can_deactivate
scope.can_deactivate?(object)
end
def can_change_trust_level
scope.can_change_trust_level?(object)
end
def ip_address
object.ip_address.try(:to_s)
end
def registration_ip_address
object.registration_ip_address.try(:to_s)
end
def include_ip_address?
scope.can_see_ip?
end
def include_registration_ip_address?
scope.can_see_ip?
end
def include_can_be_deleted?
true
end
def include_ip
@options[:include_ip]
end
end