Add notices
All checks were successful
CI / scan_ruby (push) Successful in 16s
CI / scan_js (push) Successful in 12s
CI / lint (push) Successful in 12s
CI / test (push) Successful in 39s

This commit is contained in:
sto
2025-06-21 09:59:18 +02:00
parent 2616cbaa71
commit 5b908fe37c
10 changed files with 144 additions and 70 deletions

View File

@@ -37,9 +37,9 @@ class CompletionsController < ApplicationController
if @completion.save
extend_completions!(@completion.contestant)
if @contestant && !params[:completion].key?(:message_id)
redirect_to edit_contest_contestant_path(@contest, @contestant)
redirect_to edit_contest_contestant_path(@contest, @contestant), notice: t("completions.new.notice")
else
redirect_to @contest
redirect_to @contest, notice: t("completions.new.notice")
end
else
if params[:completion].key?(:message_id)
@@ -61,9 +61,9 @@ class CompletionsController < ApplicationController
if @completion.update(completion_params)
extend_completions!(@completion.contestant)
if @contestant
redirect_to edit_contest_contestant_path(@contest, @contestant)
redirect_to edit_contest_contestant_path(@contest, @contestant), notice: t("completions.edit.notice")
else
redirect_to @contest
redirect_to @contest, notice: t("completions.edit.notice")
end
else
if @contestant
@@ -79,9 +79,9 @@ class CompletionsController < ApplicationController
@completion.destroy
if params[:contestant_id]
redirect_to contest_contestant_path(@contest, params[:contestant_id])
redirect_to contest_contestant_path(@contest, params[:contestant_id]), notice: t("completions.destroy.notice")
else
redirect_to contest_path(@contest)
redirect_to contest_path(@contest), notice: t("completions.destroy.notice")
end
end

View File

@@ -24,7 +24,7 @@ class ContestantsController < ApplicationController
@contestant = Contestant.new(contestant_params)
@contestant.contest_id = @contest.id
if @contestant.save
redirect_to contest_path(@contest)
redirect_to contest_path(@contest), notice: t("contestants.new.notice")
else
@action_name = t("helpers.buttons.back")
@action_path = contest_path(@contest)
@@ -36,7 +36,7 @@ class ContestantsController < ApplicationController
authorize @contest
if @contestant.update(contestant_params)
redirect_to @contest
redirect_to @contest, notice: t("contestants.edit.notice")
else
@action_name = t("helpers.buttons.back")
@action_path = contest_path(@contest)
@@ -48,7 +48,7 @@ class ContestantsController < ApplicationController
authorize @contest
@contestant.destroy
redirect_to contest_path(@contest)
redirect_to contest_path(@contest), notice: t("contestants.destroy.notice")
end
def import
@@ -101,7 +101,7 @@ class ContestantsController < ApplicationController
end
end
end
redirect_to contest_path(@contest)
redirect_to contest_path(@contest), notice: t("contestants.import.notice")
else
@action_name = t("helpers.buttons.back")
@action_path = contest_path(@contest)

View File

@@ -40,7 +40,7 @@ class ContestsController < ApplicationController
@contest = Contest.new(contest_params)
@contest.user_id = current_user.id
if @contest.save
redirect_to @contest
redirect_to @contest, notice: t("contests.new.notice")
else
render :new, status: :unprocessable_entity
end
@@ -50,7 +50,7 @@ class ContestsController < ApplicationController
authorize @contest
if @contest.update(contest_params)
redirect_to @contest
redirect_to @contest, notice: t("contests.edit.notice")
else
@action_name = t("helpers.buttons.back")
@action_path = contest_path(@contest)
@@ -60,6 +60,9 @@ class ContestsController < ApplicationController
def destroy
authorize @contest
@contest.destroy
redirect_to contests_path, notice: t("contests.destroy.notice")
end
def scoreboard

View File

@@ -65,7 +65,7 @@ class MessagesController < ApplicationController
@message = Message.find(params[:id])
@message.destroy
redirect_to contest_path(@contest)
redirect_to contest_path(@contest), notice: t("messages.destroy.notice")
end
private

View File

@@ -23,7 +23,7 @@ class PuzzlesController < ApplicationController
@puzzle = Puzzle.new(puzzle_params)
@puzzle.contest_id = @contest.id
if @puzzle.save
redirect_to contest_path(@contest)
redirect_to contest_path(@contest), notice: t("puzzles.new.notice")
else
@action_name = t("helpers.buttons.back")
@action_path = contest_path(@contest)
@@ -35,7 +35,7 @@ class PuzzlesController < ApplicationController
authorize @contest
if @puzzle.update(puzzle_params)
redirect_to @contest
redirect_to @contest, notice: t("puzzles.edit.notice")
else
@action_name = t("helpers.buttons.back")
@action_path = contest_path(@contest)
@@ -47,7 +47,7 @@ class PuzzlesController < ApplicationController
authorize @contest
@puzzle.destroy
redirect_to contest_path(@contest)
redirect_to contest_path(@contest), notice: t("puzzles.destroy.notice")
end
private

View File

@@ -9,7 +9,7 @@ class SessionsController < ApplicationController
def create
if user = User.authenticate_by(params.permit(:email_address, :password))
start_new_session_for user
redirect_to after_authentication_url
redirect_to after_authentication_url, notice: t("sessions.new.notice")
else
redirect_to new_session_path, alert: "Try another email address or password."
end

View File

@@ -15,7 +15,7 @@ class UsersController < ApplicationController
authorize @user
if @user.update(user_params)
redirect_to contests_path
redirect_to contests_path, notice: t("users.edit.notice")
else
render :edit, status: :unprocessable_entity
end
@@ -38,7 +38,7 @@ class UsersController < ApplicationController
@user = User.new(user_params)
if @user.save
redirect_to users_path
redirect_to users_path, notice: t("users.new.notice")
else
render :new, status: :unprocessable_entity
end

View File

@@ -16,6 +16,33 @@ html
= t("nav.settings")
= button_to t("nav.log_out"), session_path, method: :delete
css:
.toast {
opacity: 0;
animation: fadeInAndOut 6s linear;
}
@keyframes fadeInAndOut {
0%, 5%, 100% { opacity: 0 }
7%, 85% { opacity: 1 }
}
javascript:
function closeToast(event) {
event.target.parentElement.parentElement.style.display = 'none';
}
.toast-container.position-fixed.p-3 style="right: 30px; top: 100px"
- flash.each do |type, msg|
.toast role="alert" aria-live="assertive" aria-atomic="true" style="display: block"
.toast-header
strong.me-auto
i.bi-bell-fill.fs-6.text-primary
=< type.humanize
small.text-body-secondary
| Just now
button.btn-close type="button" data-bs-dismiss="toast" aria-label="Close" onclick="closeToast(event)"
.toast-body
= msg
h1.mb-4
= @title
- if @action_path