mirror of
https://github.com/discourse/discourse.git
synced 2025-06-01 02:04:53 +08:00
FEATURE: Clarify Reviewable User Actions
"Approve" is now "Approve User" and "Delete" is a dropdown with a choice that allows you to block.
This commit is contained in:
@ -12,11 +12,31 @@ class ReviewableUser < Reviewable
|
||||
def build_actions(actions, guardian, args)
|
||||
return unless pending?
|
||||
|
||||
actions.add(:approve) if guardian.can_approve?(target) || args[:approved_by_invite]
|
||||
actions.add(:reject)
|
||||
if guardian.can_approve?(target) || args[:approved_by_invite]
|
||||
actions.add(:approve_user) do |a|
|
||||
a.icon = 'user-plus'
|
||||
a.label = "reviewables.actions.approve_user.title"
|
||||
end
|
||||
end
|
||||
|
||||
reject = actions.add_bundle(
|
||||
'reject_user',
|
||||
icon: 'user-times',
|
||||
label: 'reviewables.actions.reject_user.title'
|
||||
)
|
||||
actions.add(:reject_user_delete, bundle: reject) do |a|
|
||||
a.icon = 'user-times'
|
||||
a.label = "reviewables.actions.reject_user.delete.title"
|
||||
a.description = "reviewables.actions.reject_user.delete.description"
|
||||
end
|
||||
actions.add(:reject_user_block, bundle: reject) do |a|
|
||||
a.icon = 'ban'
|
||||
a.label = "reviewables.actions.reject_user.block.title"
|
||||
a.description = "reviewables.actions.reject_user.block.description"
|
||||
end
|
||||
end
|
||||
|
||||
def perform_approve(performed_by, args)
|
||||
def perform_approve_user(performed_by, args)
|
||||
ReviewableUser.set_approved_fields!(target, performed_by)
|
||||
target.save!
|
||||
|
||||
@ -34,14 +54,17 @@ class ReviewableUser < Reviewable
|
||||
create_result(:success, :approved)
|
||||
end
|
||||
|
||||
def perform_reject(performed_by, args)
|
||||
|
||||
def perform_reject_user_delete(performed_by, args)
|
||||
# We'll delete the user if we can
|
||||
if target.present?
|
||||
destroyer = UserDestroyer.new(performed_by)
|
||||
|
||||
begin
|
||||
destroyer.destroy(target)
|
||||
delete_args = {}
|
||||
delete_args[:block_ip] = true if args[:block_ip]
|
||||
delete_args[:block_email] = true if args[:block_email]
|
||||
|
||||
destroyer.destroy(target, delete_args)
|
||||
rescue UserDestroyer::PostsExistError
|
||||
# If a user has posts, we won't delete them to preserve their content.
|
||||
# However the reviable record will be "rejected" and they will remain
|
||||
@ -53,6 +76,12 @@ class ReviewableUser < Reviewable
|
||||
create_result(:success, :rejected)
|
||||
end
|
||||
|
||||
def perform_reject_user_block(performed_by, args)
|
||||
args[:block_email] = true
|
||||
args[:block_ip] = true
|
||||
perform_reject_user_delete(performed_by, args)
|
||||
end
|
||||
|
||||
# Update's the user's fields for approval but does not save. This
|
||||
# can be used when generating a new user that is approved on create
|
||||
def self.set_approved_fields!(user, approved_by)
|
||||
|
Reference in New Issue
Block a user