Back buttons
All checks were successful
CI / scan_ruby (push) Successful in 16s
CI / scan_js (push) Successful in 12s
CI / lint (push) Successful in 13s
CI / test (push) Successful in 37s

This commit is contained in:
sto
2025-06-18 19:09:55 +02:00
parent 67d2ef41b3
commit b8674a126f
8 changed files with 67 additions and 3 deletions

View File

@@ -2,16 +2,27 @@ class CompletionsController < ApplicationController
include CompletionsConcern
before_action :set_contest
before_action :set_contestant
before_action :set_data, only: %i[ create edit new update ]
before_action :set_completion, only: %i[ destroy edit update ]
def edit
authorize @contest
if @contestant
@action_name = t("helpers.buttons.back_to_contestant")
@action_path = edit_contest_contestant_path(@contest, @contestant)
end
end
def new
authorize @contest
if @contestant
@action_name = t("helpers.buttons.back_to_contestant")
@action_path = edit_contest_contestant_path(@contest, @contestant)
end
@completion = Completion.new
if params[:contestant_id]
@completion.contestant_id = params[:contestant_id]
@@ -27,6 +38,10 @@ class CompletionsController < ApplicationController
extend_completions!(@completion.contestant)
redirect_to contest_path(@contest)
else
if @contestant
@action_name = t("helpers.buttons.back_to_contestant")
@action_path = edit_contest_contestant_path(@contest, @contestant)
end
render :new, status: :unprocessable_entity
end
end
@@ -39,6 +54,10 @@ class CompletionsController < ApplicationController
extend_completions!(@completion.contestant)
redirect_to @contest
else
if @contestant
@action_name = t("helpers.buttons.back_to_contestant")
@action_path = edit_contest_contestant_path(@contest, @contestant)
end
render :edit, status: :unprocessable_entity
end
end
@@ -60,6 +79,14 @@ class CompletionsController < ApplicationController
@contest = Contest.find(params[:contest_id])
end
def set_contestant
if params.key?(:contestant_id)
@contestant = Contestant.find(params[:contestant_id])
else
@contetant = nil
end
end
def set_data
@contestants = @contest.contestants
@puzzles = @contest.puzzles

View File

@@ -5,11 +5,16 @@ class ContestantsController < ApplicationController
def edit
authorize @contest
@action_name = t("helpers.buttons.back")
@action_path = contest_path(@contest)
end
def new
authorize @contest
@action_name = t("helpers.buttons.back")
@action_path = contest_path(@contest)
@contestant = Contestant.new
end
@@ -21,6 +26,8 @@ class ContestantsController < ApplicationController
if @contestant.save
redirect_to contest_path(@contest)
else
@action_name = t("helpers.buttons.back")
@action_path = contest_path(@contest)
render :new, status: :unprocessable_entity
end
end
@@ -31,6 +38,8 @@ class ContestantsController < ApplicationController
if @contestant.update(contestant_params)
redirect_to @contest
else
@action_name = t("helpers.buttons.back")
@action_path = contest_path(@contest)
render :edit, status: :unprocessable_entity
end
end
@@ -45,6 +54,9 @@ class ContestantsController < ApplicationController
def import
authorize @contest
@action_name = t("helpers.buttons.back")
@action_path = contest_path(@contest)
@csv_import = CsvImport.new
end
@@ -55,6 +67,8 @@ class ContestantsController < ApplicationController
if @csv_import.save
redirect_to "/contests/#{@contest.id}/import/#{@csv_import.id}"
else
@action_name = t("helpers.buttons.back")
@action_path = contest_path(@contest)
render :import, status: :unprocessable_entity
end
end

View File

@@ -23,6 +23,9 @@ class ContestsController < ApplicationController
def edit
authorize @contest
@action_name = t("helpers.buttons.back")
@action_path = contest_path(@contest)
end
def new

View File

@@ -50,6 +50,9 @@ class MessagesController < ApplicationController
def convert
authorize @contest
@action_name = t("helpers.buttons.back")
@action_path = contest_path(@contest)
@message = Message.find(params[:message_id])
@completion = Completion.new()
@completion.display_time_from_start = @message.display_time

View File

@@ -4,11 +4,16 @@ class PuzzlesController < ApplicationController
def edit
authorize @contest
@action_name = t("helpers.buttons.back")
@action_path = contest_path(@contest)
end
def new
authorize @contest
@action_name = t("helpers.buttons.back")
@action_path = contest_path(@contest)
@puzzle = Puzzle.new
end
@@ -20,6 +25,8 @@ class PuzzlesController < ApplicationController
if @puzzle.save
redirect_to contest_path(@contest)
else
@action_name = t("helpers.buttons.back")
@action_path = contest_path(@contest)
render :new, status: :unprocessable_entity
end
end
@@ -30,6 +37,8 @@ class PuzzlesController < ApplicationController
if @puzzle.update(puzzle_params)
redirect_to @contest
else
@action_name = t("helpers.buttons.back")
@action_path = contest_path(@contest)
render :edit, status: :unprocessable_entity
end
end