Add contest organizer form param
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-04-24 11:44:51 +02:00
parent 1650b22407
commit fa8880abfc
9 changed files with 29 additions and 5 deletions

View File

@@ -164,7 +164,7 @@ class ContestantsController < ApplicationController
skip_authorization skip_authorization
@contestant = Contestant.find(params[:contestant_id]) @contestant = Contestant.find(params[:contestant_id])
if !@contestant || !@contestant.contest.code.present? if !@contestant || !@contestant.contest.code.present? || !@contestant.contest.organizer_form
not_found and return not_found and return
end end
@contest = @contestant.contest @contest = @contestant.contest

View File

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

View File

@@ -10,6 +10,7 @@
# lang :string default("en") # lang :string default("en")
# name :string # name :string
# offline_form :boolean default(FALSE) # offline_form :boolean default(FALSE)
# organizer_form :boolean
# pause_time :datetime # pause_time :datetime
# public :boolean default(FALSE) # public :boolean default(FALSE)
# ranking_mode :string # ranking_mode :string

View File

@@ -1,7 +1,17 @@
= render "params_nav" = render "params_nav"
= form_with model: @contest, url: "/contests/#{@contest.id}/settings/onsite" do |form| = form_with model: @contest, url: "/contests/#{@contest.id}/settings/onsite" do |form|
.row.mt-2.mb-3 .row
.col
.alert.alert-warning role="alert"
= t("contests.nav.onsite_description")
.row.mt-1
.col
.form-check.form-switch
= form.check_box :organizer_form, class: "form-check-input"
= form.label :organizer_form
.form-text = t("activerecord.attributes.contest.organizer_form")
.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"

View File

@@ -63,6 +63,8 @@ en:
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
offline_form_warning: Only for single-puzzle contests offline_form_warning: Only for single-puzzle contests
organizer_form: Enable the public organizer forms
organizer_form_description: Required for QR codes to work.
public: Enable the public scoreboard public: Enable the public scoreboard
ranking_mode: Ranking mode (public scoreboard & CSV exports) ranking_mode: Ranking mode (public scoreboard & CSV exports)
show_stopwatch: Display the stopwatch show_stopwatch: Display the stopwatch
@@ -213,6 +215,7 @@ en:
general: General general: General
online: Online contests online: Online contests
onsite: Onsite contests onsite: Onsite contests
onsite_description: Beware once those forms are activated, the puzzle names become findable through guessing the form URL. Later I'll work on better securing them so this setting won't be necessary anymore.
public: Public scoreboard public: Public scoreboard
settings: Settings settings: Settings
stopwatch: Stopwatch stopwatch: Stopwatch

View File

@@ -25,7 +25,7 @@ fr:
projected_time: Temps projeté projected_time: Temps projeté
remaining_pieces: Pièces restantes (puzzle non fini) remaining_pieces: Pièces restantes (puzzle non fini)
contest: contest:
code: Code pour les organisateur.ice.s code: Code pour les organisateur.ices
code_description: Optionnel. Utilisé pour les organisateur.ices dans les concours en présentiel lorsque sont imprimés des QR codes à placer sur les tables code_description: Optionnel. Utilisé pour les organisateur.ices dans les concours en présentiel lorsque sont imprimés des QR codes à placer sur les tables
duration: Durée duration: Durée
duration_description: Format h:mm ou hh:mm duration_description: Format h:mm ou hh:mm
@@ -34,6 +34,8 @@ fr:
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é
offline_form_warning: Activable uniquement pour les concours avec un seul puzzle offline_form_warning: Activable uniquement pour les concours avec un seul puzzle
organizer_form: Activer les formulaires publics pour les organisateur.ices
organizer_form_description: Nécessaire pour que les QR codes fonctionnent
public: Activer le classement public public: Activer le classement public
ranking_mode: Mode de classement (classement public & exports CSV) ranking_mode: Mode de classement (classement public & exports CSV)
show_stopwatch: Afficher le chronomètre show_stopwatch: Afficher le chronomètre
@@ -184,6 +186,7 @@ fr:
general: Général general: Général
online: Concours en ligne online: Concours en ligne
onsite: Concours en présentiel onsite: Concours en présentiel
onsite_description: Attention, les URLs de ces formulaires sont actuellement techniquement devinables, et une personne mal intentionnée pourrait y trouver la liste de noms des puzzles grâce au menu déroulant présent sur ce formulaire. Je vais travailler bientôt à mieux sécuriser ces formulaires et ce paramètre deviendra alors non nécessaire. En attendant je recommande de garder ce paramètre désactivé tant que le concours n'est pas commencé.
public: Classement public public: Classement public
settings: Paramètres settings: Paramètres
stopwatch: Chronomètre stopwatch: Chronomètre

View File

@@ -0,0 +1,5 @@
class AddOrganizerFormToContest < ActiveRecord::Migration[8.0]
def change
add_column :contests, :organizer_form, :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: 2025_12_10_092658) do ActiveRecord::Schema[8.0].define(version: 2026_04_24_091108) 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
@@ -106,6 +106,7 @@ ActiveRecord::Schema[8.0].define(version: 2025_12_10_092658) do
t.datetime "start_time" t.datetime "start_time"
t.datetime "pause_time" t.datetime "pause_time"
t.boolean "show_stopwatch" t.boolean "show_stopwatch"
t.string "organizer_form"
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"
end end

View File

@@ -10,6 +10,7 @@
# lang :string default("en") # lang :string default("en")
# name :string # name :string
# offline_form :boolean default(FALSE) # offline_form :boolean default(FALSE)
# organizer_form :boolean
# pause_time :datetime # pause_time :datetime
# public :boolean default(FALSE) # public :boolean default(FALSE)
# ranking_mode :string # ranking_mode :string