Add method to update contestants through admin UI
This commit is contained in:
@@ -1,4 +1,6 @@
|
||||
class UsersController < ApplicationController
|
||||
include CompletionsConcern
|
||||
|
||||
before_action :set_user, only: %i[ destroy edit show update ]
|
||||
|
||||
def index
|
||||
@@ -51,6 +53,26 @@ class UsersController < ApplicationController
|
||||
authorize @user
|
||||
end
|
||||
|
||||
def update_contestants
|
||||
authorize :user
|
||||
|
||||
total = 0
|
||||
updated = 0
|
||||
Contestant.all.each do |contestant|
|
||||
if contestant.completions.length > 0
|
||||
total += 1
|
||||
contestant.completions.each do |completion|
|
||||
completion.save
|
||||
end
|
||||
if extend_completions!(contestant)
|
||||
updated += 1
|
||||
end
|
||||
end
|
||||
end
|
||||
|
||||
redirect_to users_path, notice: "Updated contestants: #{updated}/#{total}"
|
||||
end
|
||||
|
||||
private
|
||||
|
||||
def set_user
|
||||
|
||||
Reference in New Issue
Block a user