FIX: do not show "Send Activation Email" button if `must_approve_users` setting is enabled

https://meta.discourse.org/t/error-when-pressing-send-activitation-email-when-must-approve-users-setting-is-enabled/65408
This commit is contained in:
Arpit Jalan 2017-07-04 13:59:05 +05:30
parent a7a8ccb100
commit c243861b17
2 changed files with 5 additions and 3 deletions

View File

@ -8,8 +8,7 @@ class AdminUserSerializer < AdminUserListSerializer
:can_activate, :can_activate,
:can_deactivate, :can_deactivate,
:ip_address, :ip_address,
:registration_ip_address, :registration_ip_address
:can_send_activation_email
has_one :single_sign_on_record, serializer: SingleSignOnRecordSerializer, embed: :objects has_one :single_sign_on_record, serializer: SingleSignOnRecordSerializer, embed: :objects

View File

@ -126,9 +126,12 @@ class Guardian
end end
alias :can_move_posts? :can_moderate? alias :can_move_posts? :can_moderate?
alias :can_see_flags? :can_moderate? alias :can_see_flags? :can_moderate?
alias :can_send_activation_email? :can_moderate?
alias :can_close? :can_moderate? alias :can_close? :can_moderate?
def can_send_activation_email?(user)
user && is_staff? && !SiteSetting.must_approve_users?
end
def can_grant_badges?(_user) def can_grant_badges?(_user)
SiteSetting.enable_badges && is_staff? SiteSetting.enable_badges && is_staff?
end end