Add public scoreboard slug & URL
This commit is contained in:
@@ -69,6 +69,6 @@ class ContestsController < ApplicationController
|
||||
end
|
||||
|
||||
def contest_params
|
||||
params.expect(contest: [ :name, :team, :allow_registration ])
|
||||
params.expect(contest: [ :name, :team, :allow_registration, :slug ])
|
||||
end
|
||||
end
|
||||
|
@@ -1,13 +1,12 @@
|
||||
class SessionsController < ApplicationController
|
||||
allow_unauthenticated_access only: %i[ new create ]
|
||||
rate_limit to: 10, within: 3.minutes, only: :create, with: -> { redirect_to new_session_url, alert: "Try again later." }
|
||||
before_action :skip_authorization
|
||||
|
||||
def new
|
||||
skip_authorization
|
||||
end
|
||||
|
||||
def create
|
||||
skip_authorization
|
||||
if user = User.authenticate_by(params.permit(:email_address, :password))
|
||||
start_new_session_for user
|
||||
redirect_to after_authentication_url
|
||||
|
@@ -5,6 +5,7 @@
|
||||
# id :integer not null, primary key
|
||||
# allow_registration :boolean default(FALSE)
|
||||
# name :string
|
||||
# slug :string
|
||||
# team :boolean default(FALSE)
|
||||
# created_at :datetime not null
|
||||
# updated_at :datetime not null
|
||||
@@ -24,4 +25,7 @@ class Contest < ApplicationRecord
|
||||
has_many :completions, dependent: :destroy
|
||||
has_many :contestants, dependent: :destroy
|
||||
has_many :puzzles, dependent: :destroy
|
||||
|
||||
validates :name, presence: true
|
||||
validates :slug, presence: true, format: { with: /\A(\w|-)*\z/, message: 'Only alphanumeric characters, "-" and "_" allowed.' }
|
||||
end
|
||||
|
@@ -4,6 +4,12 @@
|
||||
.form-floating
|
||||
= form.text_field :name, autocomplete: "off", class: "form-control"
|
||||
= form.label :name, class: "required"
|
||||
.row.mb-3
|
||||
.col
|
||||
.form-floating
|
||||
= form.text_field :slug, autocomplete: "off", class: "form-control"
|
||||
= form.label :slug, class: "required"
|
||||
.form-text This will be used for building the public scoreboard URL: https://puzzle-scoreboard.org/public/<slug>.
|
||||
.row.mb-3
|
||||
.col
|
||||
.form-check.form-switch
|
||||
|
@@ -1,4 +1,4 @@
|
||||
.row.mb-2
|
||||
.row.mb-4
|
||||
.col
|
||||
css:
|
||||
.badges { margin-top: -18px; position: absolute; }
|
||||
@@ -6,10 +6,16 @@
|
||||
- @badges.each do |badge|
|
||||
span.badge.text-bg-info.me-2
|
||||
= badge
|
||||
|
||||
.row.mb-4
|
||||
.col
|
||||
.float-end
|
||||
a.btn.btn-primary href=edit_contest_path(@contest)
|
||||
| Edit contest
|
||||
|
||||
p
|
||||
|> Public scoreboard:
|
||||
= link_to root_url + "public/#{@contest.slug}"
|
||||
|
||||
.row.mb-4
|
||||
.col-6
|
||||
.row
|
||||
|
Reference in New Issue
Block a user