Make asking for missing pieces in forms optional
Some checks failed
CI / scan_ruby (push) Has been cancelled
CI / scan_js (push) Has been cancelled
CI / lint (push) Has been cancelled
CI / test (push) Has been cancelled

This commit is contained in:
sto
2026-08-25 09:26:29 +02:00
parent 95c336be65
commit 00e14b7cff
9 changed files with 20 additions and 5 deletions

View File

@@ -328,7 +328,7 @@ class ContestsController < ApplicationController
end end
def settings_onsite_params def settings_onsite_params
params.expect(contest: [ :code, :organizer_form ]) params.expect(contest: [ :code, :organizer_form, :missing_pieces ])
end end
def settings_online_params def settings_online_params

View File

@@ -8,6 +8,7 @@
# duration :string # duration :string
# duration_seconds :integer # duration_seconds :integer
# lang :string default("en") # lang :string default("en")
# missing_pieces :boolean
# name :string # name :string
# offline_form :boolean default(FALSE) # offline_form :boolean default(FALSE)
# organizer_form :boolean # organizer_form :boolean

View File

@@ -78,6 +78,7 @@
javascript: javascript:
savetime = ""; savetime = "";
ispatch = #{method == :patch}; ispatch = #{method == :patch};
showMissingPieces = #{@completion.contest.missing_pieces}
// Actions for radio buttons. // Actions for radio buttons.
completed_radio_yes_el = document.getElementById('completed_radio_yes'); completed_radio_yes_el = document.getElementById('completed_radio_yes');
@@ -90,7 +91,7 @@
if (ispatch) timeEl.value = '#{@completion.display_time_from_start}'; if (ispatch) timeEl.value = '#{@completion.display_time_from_start}';
else timeEl.value = savetime; else timeEl.value = savetime;
timeEl.parentElement.parentElement.parentElement.style.display = ''; timeEl.parentElement.parentElement.parentElement.style.display = '';
missingPiecesEl.style.display = 'block'; if (showMissingPieces) missingPiecesEl.style.display = 'block';
remainingPiecesEl.style.display = 'none'; remainingPiecesEl.style.display = 'none';
submitEl.style.display = ''; submitEl.style.display = '';
if (refreshEl) refreshEl.style.display = ''; if (refreshEl) refreshEl.style.display = '';
@@ -150,7 +151,7 @@
updateTime(); updateTime();
/ Text field for recording the missing pieces, if any. / Text field for recording the missing pieces, if any.
.row.mt-3 id="missing_pieces" style="display: #{@completion.completed ? "" : "none"};" .row.mt-3 id="missing_pieces" style="display: #{@completion.completed && @completion.contest.missing_pieces ? "" : "none"};"
.col .col
.form-floating .form-floating
= form.text_field :missing_pieces, autocomplete: "off", class: "form-control" = form.text_field :missing_pieces, autocomplete: "off", class: "form-control"

View File

@@ -10,13 +10,17 @@
.form-check.form-switch .form-check.form-switch
= form.check_box :organizer_form, class: "form-check-input" = form.check_box :organizer_form, class: "form-check-input"
= form.label :organizer_form = form.label :organizer_form
.form-text = t("activerecord.attributes.contest.organizer_form")
.row.mt-3.mb-3 .row.mt-3.mb-3
.col .col
.form-floating .form-floating
= form.text_field :code, autocomplete: "off", class: "form-control" = form.text_field :code, autocomplete: "off", class: "form-control"
= form.label :code, class: "required" = form.label :code, class: "required"
.form-text = t("activerecord.attributes.contest.code_description") .form-text = t("activerecord.attributes.contest.code_description")
.row.mt-1
.col
.form-check.form-switch
= form.check_box :missing_pieces, class: "form-check-input"
= form.label :missing_pieces
.row.mt-4 .row.mt-4
.col .col
= form.submit t("helpers.buttons.update"), class: "btn btn-primary" = form.submit t("helpers.buttons.update"), class: "btn btn-primary"

View File

@@ -59,6 +59,7 @@ en:
duration: Duration duration: Duration
duration_description: Format h:mm or hh:mm duration_description: Format h:mm or hh:mm
lang: Language for the public scoreboard lang: Language for the public scoreboard
missing_pieces: Ask for missing pieces for completed puzzles
name: Name name: Name
offline_form: Enable the offline participation form offline_form: Enable the offline participation form
offline_form_description: Offline participants will have to fill the form by providing an image taken of the puzzle before starting solving it, and validate their finish time with an upload of an image of the completed puzzle offline_form_description: Offline participants will have to fill the form by providing an image taken of the puzzle before starting solving it, and validate their finish time with an upload of an image of the completed puzzle

View File

@@ -30,6 +30,7 @@ fr:
duration: Durée duration: Durée
duration_description: Format h:mm ou hh:mm duration_description: Format h:mm ou hh:mm
lang: Langue pour le classement public lang: Langue pour le classement public
missing_pieces: Demander le nombre de pièces manquantes pour les puzzles complétés
name: Nom name: Nom
offline_form: Activer le formulaire de participation hors-ligne offline_form: Activer le formulaire de participation hors-ligne
offline_form_description: Les participant.e.s hors-ligne pourront participer en prenant une photo du puzzle avant de le commencer, puis valider leur temps avec une photo du puzzle une fois complété offline_form_description: Les participant.e.s hors-ligne pourront participer en prenant une photo du puzzle avant de le commencer, puis valider leur temps avec une photo du puzzle une fois complété

View File

@@ -0,0 +1,5 @@
class AddMissingPiecesToContest < ActiveRecord::Migration[8.0]
def change
add_column :contests, :missing_pieces, :boolean
end
end

3
db/schema.rb generated
View File

@@ -10,7 +10,7 @@
# #
# It's strongly recommended that you check this file into your version control system. # It's strongly recommended that you check this file into your version control system.
ActiveRecord::Schema[8.0].define(version: 2026_07_30_055752) do ActiveRecord::Schema[8.0].define(version: 2026_08_25_071844) do
create_table "active_storage_attachments", force: :cascade do |t| create_table "active_storage_attachments", force: :cascade do |t|
t.string "name", null: false t.string "name", null: false
t.string "record_type", null: false t.string "record_type", null: false
@@ -107,6 +107,7 @@ ActiveRecord::Schema[8.0].define(version: 2026_07_30_055752) do
t.boolean "show_stopwatch" t.boolean "show_stopwatch"
t.boolean "organizer_form" t.boolean "organizer_form"
t.integer "event_id" t.integer "event_id"
t.boolean "missing_pieces"
t.index ["event_id"], name: "index_contests_on_event_id" t.index ["event_id"], name: "index_contests_on_event_id"
t.index ["slug"], name: "index_contests_on_slug", unique: true t.index ["slug"], name: "index_contests_on_slug", unique: true
t.index ["user_id"], name: "index_contests_on_user_id" t.index ["user_id"], name: "index_contests_on_user_id"

View File

@@ -8,6 +8,7 @@
# duration :string # duration :string
# duration_seconds :integer # duration_seconds :integer
# lang :string default("en") # lang :string default("en")
# missing_pieces :boolean
# name :string # name :string
# offline_form :boolean default(FALSE) # offline_form :boolean default(FALSE)
# organizer_form :boolean # organizer_form :boolean