Improve completions
Some checks are pending
CI / scan_ruby (push) Waiting to run
CI / scan_js (push) Waiting to run
CI / lint (push) Waiting to run
CI / test (push) Waiting to run

This commit is contained in:
sto 2025-03-21 19:50:03 +01:00
parent 15e2493f87
commit 570e517c28
3 changed files with 11 additions and 3 deletions

View File

@ -22,7 +22,7 @@ class CompletionsController < ApplicationController
redirect_to contest_path(@contest)
else
logger = Logger.new(STDOUT)
logger.info(@completion.errors.full_messages)
logger.info(@completion.errors)
@title = "New completion"
render :new, status: :unprocessable_entity
end
@ -42,7 +42,11 @@ class CompletionsController < ApplicationController
def destroy
@completion.destroy
redirect_to contest_path(@contest)
if params[:contestant_id]
redirect_to contest_contestant_path(@contest, params[:contestant_id])
else
redirect_to contest_path(@contest)
end
end
private

View File

@ -6,4 +6,6 @@ class Completion < ApplicationRecord
attr_accessor :display_time_from_start, :display_relative_time
validates :time_seconds, presence: true
validates_numericality_of :time_seconds
validates :puzzle_id, uniqueness: { score: :contestant }
end

View File

@ -43,8 +43,10 @@
td
| #{completion.puzzle.name} - #{completion.puzzle.brand}
td
a.btn.btn-sm.btn-secondary href=edit_contest_completion_path(@contest, completion, contestant.id)
a.btn.btn-sm.btn-secondary.me-2 href=edit_contest_completion_path(@contest, completion, contestant.id)
| Edit
= link_to "Delete", contest_completion_path(contest, completion, contestant_id: contestant.id),
data: { turbo_method: :delete }, class: "btn btn-sm btn-secondary"
.row
.col
a.btn.btn-primary href=new_contest_completion_path(@contest, contestant_id: contestant.id)