Add "public" setting to contests
This commit is contained in:
parent
1a8ea0afee
commit
2b1a2c9296
@ -67,7 +67,7 @@ class ContestsController < ApplicationController
|
||||
|
||||
def scoreboard
|
||||
@contest = Contest.find_by(slug: params[:id])
|
||||
unless @contest
|
||||
unless @contest && @contest.public
|
||||
skip_authorization
|
||||
not_found and return
|
||||
end
|
||||
@ -94,6 +94,6 @@ class ContestsController < ApplicationController
|
||||
end
|
||||
|
||||
def contest_params
|
||||
params.expect(contest: [ :lang, :name, :team, :allow_registration ])
|
||||
params.expect(contest: [ :lang, :name, :public, :team, :allow_registration ])
|
||||
end
|
||||
end
|
||||
|
@ -6,6 +6,7 @@
|
||||
# allow_registration :boolean default(FALSE)
|
||||
# lang :string default("en")
|
||||
# name :string
|
||||
# public :boolean default(FALSE)
|
||||
# slug :string
|
||||
# team :boolean default(FALSE)
|
||||
# created_at :datetime not null
|
||||
|
@ -9,6 +9,11 @@
|
||||
.form-floating
|
||||
= form.select :lang, Languages::AVAILABLE_LANGUAGES.map { |lang| [ lang[:name], lang[:id] ] }, {}, class: "form-select"
|
||||
= form.label :lang
|
||||
.row.mb-3
|
||||
.col
|
||||
.form-check.form-switch
|
||||
= form.check_box :public, class: "form-check-input"
|
||||
= form.label :public
|
||||
.row.mb-3
|
||||
.col
|
||||
.form-check.form-switch
|
||||
|
@ -14,8 +14,12 @@ javascript:
|
||||
|
||||
.row.mb-5
|
||||
.col
|
||||
- if @contest.public
|
||||
a.btn.btn-success href="/public/#{@contest.slug}"
|
||||
= t("contests.show.open_public_scoreboard")
|
||||
- else
|
||||
a.btn.btn-success.disabled
|
||||
= t("contests.show.public_scoreboard_disabled")
|
||||
button.btn.btn-success.ms-3 onclick="copyExtensionUrlToClipboard()"
|
||||
css:
|
||||
button > svg {
|
||||
|
@ -47,6 +47,7 @@ en:
|
||||
contest:
|
||||
lang: Language for the public scoreboard
|
||||
name: Name
|
||||
public: Enable the public scoreboard
|
||||
team: Team contest
|
||||
team_description: For UI display purposes mainly
|
||||
allow_registration: Allow registration
|
||||
@ -141,6 +142,7 @@ en:
|
||||
add_puzzle: Add puzzle
|
||||
copy_extension_url: Copy the URL for connecting from the browser extension
|
||||
open_public_scoreboard: Open public scoreboard
|
||||
public_scoreboard_disabled: The public scoreboard is disabled
|
||||
url_copied: URL copied to the clipboard
|
||||
contestants:
|
||||
convert_csv:
|
||||
|
@ -18,6 +18,7 @@ fr:
|
||||
contest:
|
||||
lang: Langue pour le classement public
|
||||
name: Nom
|
||||
public: Activer le classement public
|
||||
team: Concours par équipes
|
||||
team_description: Principalement pour des raisons d'affichage
|
||||
allow_registration: Autoriser l'inscription via l'interface
|
||||
@ -112,6 +113,7 @@ fr:
|
||||
add_puzzle: Ajouter un puzzle
|
||||
copy_extension_url: Copier l'URL pour la connexion depuis l'extension web
|
||||
open_public_scoreboard: Ouvrir le classement public
|
||||
public_scoreboard_disabled: Le classement public n'est pas activé
|
||||
url_copied: L’URL a été copiée dans le presse-papier
|
||||
contestants:
|
||||
convert_csv:
|
||||
|
5
db/migrate/20250625075513_add_public_to_contest.rb
Normal file
5
db/migrate/20250625075513_add_public_to_contest.rb
Normal file
@ -0,0 +1,5 @@
|
||||
class AddPublicToContest < ActiveRecord::Migration[8.0]
|
||||
def change
|
||||
add_column :contests, :public, :boolean, default: false
|
||||
end
|
||||
end
|
3
db/schema.rb
generated
3
db/schema.rb
generated
@ -10,7 +10,7 @@
|
||||
#
|
||||
# It's strongly recommended that you check this file into your version control system.
|
||||
|
||||
ActiveRecord::Schema[8.0].define(version: 2025_06_20_051905) do
|
||||
ActiveRecord::Schema[8.0].define(version: 2025_06_25_075513) do
|
||||
create_table "active_storage_attachments", force: :cascade do |t|
|
||||
t.string "name", null: false
|
||||
t.string "record_type", null: false
|
||||
@ -75,6 +75,7 @@ ActiveRecord::Schema[8.0].define(version: 2025_06_20_051905) do
|
||||
t.boolean "allow_registration", default: false
|
||||
t.string "slug"
|
||||
t.string "lang", default: "en"
|
||||
t.boolean "public", default: false
|
||||
t.index ["slug"], name: "index_contests_on_slug", unique: true
|
||||
t.index ["user_id"], name: "index_contests_on_user_id"
|
||||
end
|
||||
|
@ -6,6 +6,7 @@
|
||||
# allow_registration :boolean default(FALSE)
|
||||
# lang :string default("en")
|
||||
# name :string
|
||||
# public :boolean default(FALSE)
|
||||
# slug :string
|
||||
# team :boolean default(FALSE)
|
||||
# created_at :datetime not null
|
||||
|
Loading…
x
Reference in New Issue
Block a user