Use contestant IDs instead of tokens for QR codes
All checks were successful
CI / scan_ruby (push) Successful in 20s
CI / scan_js (push) Successful in 13s
CI / lint (push) Successful in 13s
CI / test (push) Successful in 37s

#6
This commit is contained in:
sto
2025-12-04 10:30:44 +01:00
parent cd41d83429
commit d08370f5f8
4 changed files with 27 additions and 23 deletions

View File

@@ -122,12 +122,16 @@ class ContestantsController < ApplicationController
def generate_qrcodes
authorize @contest
generate_contestants_qrcodes(@contest)
@contestants = @contest.contestants.sort_by { |contestant| contestant.name }
end
def generate_qrcodes_pdf
authorize @contest
generate_contestants_qrcodes(@contest)
@contestants = @contest.contestants.sort_by { |contestant| contestant.name }
@nonav = true
@@ -139,7 +143,7 @@ class ContestantsController < ApplicationController
def get_public_completion
skip_authorization
@contestant = Contestant.find_by_token_for(:token, params[:token])
@contestant = Contestant.find(params[:contestant_id])
if !@contestant
not_found and return
end
@@ -156,7 +160,7 @@ class ContestantsController < ApplicationController
def post_public_completion
skip_authorization
@contestant = Contestant.find_by_token_for(:token, params[:token])
@contestant = Contestant.find(params[:contestant_id])
if !@contestant
not_found and return
end
@@ -186,7 +190,7 @@ class ContestantsController < ApplicationController
def public_completion_updated
skip_authorization
@contestant = Contestant.find_by_token_for(:token, params[:token])
@contestant = Contestant.find(params[:contestant_id])
if !@contestant
not_found and return
end
@@ -235,4 +239,11 @@ class ContestantsController < ApplicationController
def completion_params
params.expect(completion: [ :display_time_from_start, :completed, :missing_pieces, :remaining_pieces, :puzzle_id, :code ])
end
def generate_contestants_qrcodes(contest)
contest.contestants.where(qrcode: nil).each do |contestant|
contestant.generate_qrcode
contestant.save
end
end
end