Add contest param for offline form participation
Some checks failed
CI / scan_ruby (push) Successful in 20s
CI / scan_js (push) Successful in 15s
CI / lint (push) Failing after 13s
CI / test (push) Successful in 38s

This commit is contained in:
sto
2025-10-30 10:30:32 +01:00
parent 35ad7da355
commit aea001cdf6
9 changed files with 30 additions and 3 deletions

View File

@@ -101,7 +101,7 @@ class ContestsController < ApplicationController
def offline_new def offline_new
@contest = Contest.find_by(slug: params[:id]) @contest = Contest.find_by(slug: params[:id])
unless @contest && @contest.public unless @contest && @contest.offline_form
skip_authorization skip_authorization
not_found and return not_found and return
end end
@@ -127,7 +127,7 @@ class ContestsController < ApplicationController
end end
def contest_params def contest_params
params.expect(contest: [ :lang, :name, :public, :team, :allow_registration ]) params.expect(contest: [ :lang, :name, :offline_form, :public, :team, :allow_registration ])
end end
def filter_contestants_per_category def filter_contestants_per_category

View File

@@ -6,6 +6,7 @@
# allow_registration :boolean default(FALSE) # allow_registration :boolean default(FALSE)
# lang :string default("en") # lang :string default("en")
# name :string # name :string
# offline_form :boolean default(FALSE)
# public :boolean default(FALSE) # public :boolean default(FALSE)
# slug :string # slug :string
# team :boolean default(FALSE) # team :boolean default(FALSE)

View File

@@ -15,6 +15,11 @@ h4.mt-5 = t("contests.form.general")
.form-check.form-switch .form-check.form-switch
= form.check_box :public, class: "form-check-input" = form.check_box :public, class: "form-check-input"
= form.label :public = form.label :public
.row.mb-3
.col
.form-check.form-switch
= form.check_box :offline_form, class: "form-check-input"
= form.label :offline_form
.row.mb-3 .row.mb-3
.col .col
.form-check.form-switch .form-check.form-switch

View File

@@ -20,6 +20,12 @@ javascript:
- else - else
a.btn.btn-success.disabled a.btn.btn-success.disabled
= t("contests.show.public_scoreboard_disabled") = t("contests.show.public_scoreboard_disabled")
- if @contest.offline_form
a.ms-3.btn.btn-success href="/public/#{@contest.slug}/offline"
= t("contests.show.open_offline_form")
- else
a.ms-3.btn.btn-success.disabled
= t("contests.show.offline_form_disabled")
button.btn.btn-success.ms-3 onclick="copyExtensionUrlToClipboard()" button.btn.btn-success.ms-3 onclick="copyExtensionUrlToClipboard()"
css: css:
button > svg { button > svg {

View File

@@ -53,6 +53,8 @@ en:
contest: contest:
lang: Language for the public scoreboard lang: Language for the public scoreboard
name: Name name: Name
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 undone puzzle, and validate their finish time with an upload of an image of the completed puzzle
public: Enable the public scoreboard public: Enable the public scoreboard
team: Team contest team: Team contest
team_description: For UI display purposes mainly team_description: For UI display purposes mainly
@@ -162,7 +164,9 @@ en:
add_participant: Add participant add_participant: Add participant
add_puzzle: Add puzzle add_puzzle: Add puzzle
copy_extension_url: Copy the URL for connecting from the browser extension copy_extension_url: Copy the URL for connecting from the browser extension
open_offline_form: Open offline form
open_public_scoreboard: Open public scoreboard open_public_scoreboard: Open public scoreboard
offline_form_disabled: The offline form is disabled
public_scoreboard_disabled: The public scoreboard is disabled public_scoreboard_disabled: The public scoreboard is disabled
url_copied: URL copied to the clipboard url_copied: URL copied to the clipboard
contestants: contestants:

View File

@@ -24,6 +24,8 @@ fr:
contest: contest:
lang: Langue pour le classement public lang: Langue pour le classement public
name: Nom name: Nom
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 non fait, puis valider leur temps avec une photo du puzzle une fois complété
public: Activer le classement public public: Activer le classement public
team: Concours par équipes team: Concours par équipes
team_description: Principalement pour des raisons d'affichage team_description: Principalement pour des raisons d'affichage
@@ -133,7 +135,9 @@ fr:
add_participant: Ajouter un.e participant.e add_participant: Ajouter un.e participant.e
add_puzzle: Ajouter un puzzle add_puzzle: Ajouter un puzzle
copy_extension_url: Copier l'URL pour la connexion depuis l'extension web copy_extension_url: Copier l'URL pour la connexion depuis l'extension web
open_offline_form: Ouvrir le formulaire hors-ligne
open_public_scoreboard: Ouvrir le classement public open_public_scoreboard: Ouvrir le classement public
offline_form_disabled: Le formulaire hors-ligne n'est pas activé
public_scoreboard_disabled: Le classement public n'est pas activé public_scoreboard_disabled: Le classement public n'est pas activé
url_copied: LURL a été copiée dans le presse-papier url_copied: LURL a été copiée dans le presse-papier
contestants: contestants:

View File

@@ -0,0 +1,5 @@
class AddOfflineFormToContest < ActiveRecord::Migration[8.0]
def change
add_column :contests, :offline_form, :boolean, default: false
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_10_29_155116) do ActiveRecord::Schema[8.0].define(version: 2025_10_30_092221) 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
@@ -92,6 +92,7 @@ ActiveRecord::Schema[8.0].define(version: 2025_10_29_155116) do
t.string "slug" t.string "slug"
t.string "lang", default: "en" t.string "lang", default: "en"
t.boolean "public", default: false t.boolean "public", default: false
t.boolean "offline_form", default: false
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

@@ -6,6 +6,7 @@
# allow_registration :boolean default(FALSE) # allow_registration :boolean default(FALSE)
# lang :string default("en") # lang :string default("en")
# name :string # name :string
# offline_form :boolean default(FALSE)
# public :boolean default(FALSE) # public :boolean default(FALSE)
# slug :string # slug :string
# team :boolean default(FALSE) # team :boolean default(FALSE)