Add judges codes
This commit is contained in:
@@ -123,12 +123,6 @@ class ContestantsController < ApplicationController
|
||||
def generate_qrcodes
|
||||
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 }
|
||||
end
|
||||
|
||||
@@ -140,6 +134,7 @@ class ContestantsController < ApplicationController
|
||||
not_found and return
|
||||
end
|
||||
@contest = @contestant.contest
|
||||
I18n.locale = @contest.lang
|
||||
@puzzles = @contest.puzzles
|
||||
@completion = Completion.new
|
||||
@completion.completed = true
|
||||
@@ -156,16 +151,24 @@ class ContestantsController < ApplicationController
|
||||
not_found and return
|
||||
end
|
||||
@contest = @contestant.contest
|
||||
I18n.locale = @contest.lang
|
||||
|
||||
@completion = Completion.new(completion_params)
|
||||
@completion.contest = @contest
|
||||
@completion.contestant = @contestant
|
||||
if !@completion.code.present?
|
||||
to_modify = true
|
||||
@completion.code = "incorrect-xZy"
|
||||
end
|
||||
if @completion.save
|
||||
extend_completions!(@completion.contestant)
|
||||
redirect_to "/public/p/#{params[:token]}/updated"
|
||||
else
|
||||
@puzzles = @contest.puzzles
|
||||
@public = true
|
||||
if to_modify
|
||||
@completion.code = nil
|
||||
end
|
||||
render "completions/_form", locals: { completion: @completion, submit_text: t("helpers.buttons.create"), method: :post, url: "/public/p/#{params[:token]}" }, status: :unprocessable_entity
|
||||
end
|
||||
end
|
||||
@@ -177,6 +180,7 @@ class ContestantsController < ApplicationController
|
||||
if !@contestant
|
||||
not_found and return
|
||||
end
|
||||
I18n.locale = @contestant.contest.lang
|
||||
end
|
||||
|
||||
private
|
||||
@@ -219,6 +223,6 @@ class ContestantsController < ApplicationController
|
||||
end
|
||||
|
||||
def completion_params
|
||||
params.expect(completion: [ :display_time_from_start, :completed, :missing_pieces, :remaining_pieces, :puzzle_id ])
|
||||
params.expect(completion: [ :display_time_from_start, :completed, :missing_pieces, :remaining_pieces, :puzzle_id, :code ])
|
||||
end
|
||||
end
|
||||
|
||||
Reference in New Issue
Block a user