diff --git a/app/controllers/completions_controller.rb b/app/controllers/completions_controller.rb index a9de7af..4679402 100644 --- a/app/controllers/completions_controller.rb +++ b/app/controllers/completions_controller.rb @@ -36,9 +36,17 @@ class CompletionsController < ApplicationController @completion.contest_id = @contest.id if @completion.save extend_completions!(@completion.contestant) - redirect_to contest_path(@contest) + if @contestant && !params[:completion].key?(:message_id) + redirect_to edit_contest_contestant_path(@contest, @contestant) + else + redirect_to @contest + end else - if @contestant + if params[:completion].key?(:message_id) + @message = Message.find(params[:completion][:message_id]) + @action_name = t("helpers.buttons.back") + @action_path = contest_path(@contest) + elsif @contestant @action_name = t("helpers.buttons.back_to_contestant") @action_path = edit_contest_contestant_path(@contest, @contestant) end diff --git a/app/models/completion.rb b/app/models/completion.rb index 03a1eda..8468002 100644 --- a/app/models/completion.rb +++ b/app/models/completion.rb @@ -44,6 +44,8 @@ class Completion < ApplicationRecord self.time_seconds = arr[0].to_i * 3600 + arr[1].to_i * 60 + arr[2].to_i elsif arr.size == 2 self.time_seconds = arr[0].to_i * 60 + arr[1].to_i + elsif arr.size == 1 + self.time_seconds = arr[0].to_i end end end diff --git a/config/locales/en.yml b/config/locales/en.yml index 85674cf..9e801b1 100644 --- a/config/locales/en.yml +++ b/config/locales/en.yml @@ -111,10 +111,10 @@ en: blank: Your username cannot be empty completions: edit: - title: "Edit completion" + title: Edit completion new: - title: "New completion" - singular: "completion" + title: New completion + singular: completion contests: edit: title: "Edit contest settings" @@ -176,7 +176,7 @@ en: rank: Rank messages: convert: - title: "New completion" + title: New completion plural: "messages" singular: "message" warning: "You first need to add a puzzle before converting messages to completions." diff --git a/config/locales/fr.yml b/config/locales/fr.yml index 6d56c77..7536089 100644 --- a/config/locales/fr.yml +++ b/config/locales/fr.yml @@ -82,10 +82,10 @@ fr: blank: Le nom d'utilisateur.ice est obligatoire completions: edit: - title: "Modifier la complétion" + title: Modifier la complétion new: - title: "Nouvelle complétion" - singular: "complétion" + title: Ajout d'une complétion + singular: complétion contests: edit: title: "Paramètres du concours" @@ -147,7 +147,7 @@ fr: rank: Rang messages: convert: - title: "Ajout d'une complétion" + title: Ajout d'une complétion plural: "messages" singular: "message" warning: "Au moins un puzzle doit être ajouté avant de pouvoir convertir des messages en complétions."