Add admin action to regenerate QR codes
Some checks failed
CI / scan_ruby (push) Failing after 12s
CI / scan_js (push) Failing after 10s
CI / lint (push) Successful in 13s
CI / test (push) Failing after 39s

This commit is contained in:
sto
2025-11-21 10:53:23 +01:00
parent db6f732e63
commit ae3c7c73e1
5 changed files with 20 additions and 1 deletions

View File

@@ -73,6 +73,15 @@ class UsersController < ApplicationController
redirect_to users_path, notice: "Updated contestants: #{updated}/#{total}"
end
def regenerate_qrcodes
authorize :user
Contestant.all.each do |contestant|
contestant.regenerate_qrcode
contestant.save
end
end
private
def set_user

View File

@@ -43,6 +43,10 @@ class Contestant < ApplicationRecord
end
end
def regenerate_qrcode
generate_qrcode
end
private
def initialize_time_seconds_if_empty

View File

@@ -30,4 +30,8 @@ class UserPolicy < ApplicationPolicy
def update_contestants?
user.admin?
end
def regenerate_qrcodes?
user.admin?
end
end

View File

@@ -26,3 +26,4 @@ table.table.table-striped.table-hover
a.btn.btn-primary href=new_user_path
| New user
= button_to "Update contestants", "/update_contestants", method: :post, class: "mt-3 btn btn-success"
= button_to "Regenerate QR codes", "/regenerate_qrcodes", method: :post, class: "mt-3 btn btn-success"

View File

@@ -37,6 +37,7 @@ Rails.application.routes.draw do
post "connect", to: "messages#connect"
post "message", to: "messages#create"
post "regenerate_qrcodes", to: "users#regenerate_qrcodes"
post "update_contestants", to: "users#update_contestants"
get "public/:id", to: "contests#scoreboard"