FEATURE: Replace existing badge owners when using the bulk award feature (#8770)

* FEATURE: Replace existing badge owners when using the bulk award feature

* Use ActiveRecord to sanitize title update query, Change replace checkbox text

Co-Authored-By: Robin Ward <robin.ward@gmail.com>

Co-authored-by: Robin Ward <robin.ward@gmail.com>
This commit is contained in:
Roman Rizzi
2020-01-23 14:14:58 -03:00
committed by GitHub
parent db5373a87c
commit 9eb622985a
6 changed files with 55 additions and 0 deletions

View File

@ -43,6 +43,9 @@ class Admin::BadgesController < Admin::AdminController
badge = Badge.find_by(id: params[:badge_id])
raise Discourse::InvalidParameters if csv_file.try(:tempfile).nil? || badge.nil?
replace_badge_owners = params[:replace_badge_owners] == 'true'
BadgeGranter.revoke_all(badge) if replace_badge_owners
batch_number = 1
line_number = 1
batch = []