Add PDF generation for QR codes
This commit is contained in:
@@ -2,7 +2,7 @@ class ContestantsController < ApplicationController
|
||||
include CompletionsConcern
|
||||
include ContestantsConcern
|
||||
|
||||
before_action :set_contest, only: %i[ index edit new create update destroy import upload_csv convert_csv finalize_import export generate_qrcodes ]
|
||||
before_action :set_contest, only: %i[ index edit new create update destroy import upload_csv convert_csv finalize_import export generate_qrcodes generate_qrcodes_pdf ]
|
||||
before_action :set_contestant, only: %i[ destroy edit update]
|
||||
before_action :set_completions, only: %i[edit update ]
|
||||
skip_before_action :require_authentication, only: %i[ get_public_completion post_public_completion public_completion_updated ]
|
||||
@@ -96,7 +96,6 @@ class ContestantsController < ApplicationController
|
||||
if @form.email_column == -1
|
||||
Contestant.create(name: row[@form.name_column], contest: @contest)
|
||||
else
|
||||
logger.info("Email")
|
||||
Contestant.create(name: row[@form.name_column], email: row[@form.email_column], contest: @contest)
|
||||
end
|
||||
end
|
||||
@@ -115,7 +114,7 @@ class ContestantsController < ApplicationController
|
||||
respond_to do |format|
|
||||
format.csv do
|
||||
response.headers["Content-Type"] = "text/csv"
|
||||
response.headers["Content-Disposition"] = "attachment; filename=export.csv"
|
||||
response.headers["Content-Disposition"] = "attachment; filename=#{contest.friendly_id}_results.csv"
|
||||
end
|
||||
end
|
||||
end
|
||||
@@ -126,6 +125,18 @@ class ContestantsController < ApplicationController
|
||||
@contestants = @contest.contestants.sort_by { |contestant| contestant.name }
|
||||
end
|
||||
|
||||
def generate_qrcodes_pdf
|
||||
authorize @contest
|
||||
|
||||
@contestants = @contest.contestants.sort_by { |contestant| contestant.name }
|
||||
@nonav = true
|
||||
|
||||
respond_to do |format|
|
||||
format.html
|
||||
format.pdf { render ferrum_pdf: {}, disposition: :inline, filename: "#{@contest.friendly_id}_qrcodes.pdf", layout: "blank" }
|
||||
end
|
||||
end
|
||||
|
||||
def get_public_completion
|
||||
skip_authorization
|
||||
|
||||
|
||||
Reference in New Issue
Block a user