Generate QR codes when not present and asked for
This commit is contained in:
@@ -123,6 +123,12 @@ class ContestantsController < ApplicationController
|
|||||||
def generate_qrcodes
|
def generate_qrcodes
|
||||||
authorize @contest
|
authorize @contest
|
||||||
|
|
||||||
|
@contest.contestants.each do |contestant|
|
||||||
|
if !contestant.qrcode.present?
|
||||||
|
contestant.public_generate_qrcode
|
||||||
|
contestant.save
|
||||||
|
end
|
||||||
|
end
|
||||||
@contestants = @contest.contestants.sort_by { |contestant| contestant.name }
|
@contestants = @contest.contestants.sort_by { |contestant| contestant.name }
|
||||||
end
|
end
|
||||||
|
|
||||||
|
|||||||
@@ -43,6 +43,10 @@ class Contestant < ApplicationRecord
|
|||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
|
def public_generate_qrcode
|
||||||
|
self.generate_qrcode
|
||||||
|
end
|
||||||
|
|
||||||
private
|
private
|
||||||
|
|
||||||
def initialize_time_seconds_if_empty
|
def initialize_time_seconds_if_empty
|
||||||
|
|||||||
@@ -7,5 +7,6 @@
|
|||||||
- if row * 4 + col < @contestants.length
|
- if row * 4 + col < @contestants.length
|
||||||
.d-flex.flex-column.ms-5 style="align-items: center"
|
.d-flex.flex-column.ms-5 style="align-items: center"
|
||||||
= @contestants[row * 4 + col].name
|
= @contestants[row * 4 + col].name
|
||||||
|
- if @contestants[row * 4 + col].qrcode.present?
|
||||||
.mt-1 style="width: 200px; height: 200px;"
|
.mt-1 style="width: 200px; height: 200px;"
|
||||||
= @contestants[row * 4 + col].qrcode.html_safe
|
= @contestants[row * 4 + col].qrcode.html_safe
|
||||||
Reference in New Issue
Block a user