Multiples traductions
This commit is contained in:
parent
4645b45f5d
commit
79fb1edfaf
@ -76,6 +76,8 @@ class ContestantsController < ApplicationController
|
||||
def convert_csv
|
||||
authorize @contest
|
||||
|
||||
@action_name = t("helpers.buttons.back")
|
||||
@action_path = contest_path(@contest)
|
||||
@csv_import = CsvImport.find(params[:id])
|
||||
@content = JSON.parse(@csv_import.content)
|
||||
@form = Forms::CsvConversionForm.new
|
||||
@ -92,15 +94,17 @@ class ContestantsController < ApplicationController
|
||||
@content.each_with_index do |row, i|
|
||||
if all_params["row_#{i}".to_sym] == "1"
|
||||
if @form.email_column == -1
|
||||
Contestant.create(name: row[@form.name_column], contest: @contest, time_seconds: 0)
|
||||
Contestant.create(name: row[@form.name_column], contest: @contest)
|
||||
else
|
||||
logger.info("Email")
|
||||
Contestant.create(name: row[@form.name_column], email: row[@form.email_column], contest: @contest, time_seconds: 0)
|
||||
Contestant.create(name: row[@form.name_column], email: row[@form.email_column], contest: @contest)
|
||||
end
|
||||
end
|
||||
end
|
||||
redirect_to contest_path(@contest)
|
||||
else
|
||||
@action_name = t("helpers.buttons.back")
|
||||
@action_path = contest_path(@contest)
|
||||
render :convert_csv, status: :unprocessable_entity
|
||||
end
|
||||
end
|
||||
|
@ -52,6 +52,8 @@ class ContestsController < ApplicationController
|
||||
if @contest.update(contest_params)
|
||||
redirect_to @contest
|
||||
else
|
||||
@action_name = t("helpers.buttons.back")
|
||||
@action_path = contest_path(@contest)
|
||||
render :edit, status: :unprocessable_entity
|
||||
end
|
||||
end
|
||||
|
@ -23,14 +23,16 @@ class Contestant < ApplicationRecord
|
||||
belongs_to :contest
|
||||
has_many :completions, dependent: :destroy
|
||||
|
||||
before_create :initialize_time_seconds
|
||||
before_validation :initialize_time_seconds_if_empty
|
||||
|
||||
validates :name, presence: true
|
||||
validates :time_seconds, presence: true
|
||||
|
||||
private
|
||||
|
||||
def initialize_time_seconds
|
||||
self.time_seconds = 0
|
||||
def initialize_time_seconds_if_empty
|
||||
if !self.time_seconds
|
||||
self.time_seconds = 0
|
||||
end
|
||||
end
|
||||
end
|
||||
|
@ -24,5 +24,4 @@ class Puzzle < ApplicationRecord
|
||||
has_one_attached :image
|
||||
|
||||
validates :name, presence: true
|
||||
validates :brand, presence: true
|
||||
end
|
||||
|
@ -1 +1 @@
|
||||
= render "form", contest: @contest, completion: @completion, submit_text: "Save", method: :patch, url: "/contests/#{@contest.id}/completions/#{@completion.id}"
|
||||
= render "form", contest: @contest, completion: @completion, submit_text: t("helpers.buttons.save"), method: :patch, url: "/contests/#{@contest.id}/completions/#{@completion.id}"
|
@ -1 +1 @@
|
||||
= render "form", completion: @completion, submit_text: "Create", method: :post, url: "/contests/#{@contest.id}/completions"
|
||||
= render "form", completion: @completion, submit_text: t("helpers.buttons.create"), method: :post, url: "/contests/#{@contest.id}/completions"
|
@ -13,11 +13,12 @@
|
||||
.form-floating
|
||||
= form.text_field :email, autocomplete: "off", class: "form-control"
|
||||
= form.label :email
|
||||
.form-text Optional. Fill this only if you intend to send emails through this app.
|
||||
.form-text
|
||||
= t("activerecord.attributes.contestant.email_description")
|
||||
.row.mt-4
|
||||
.col
|
||||
- if method == :patch
|
||||
= link_to "Delete", contest_contestant_path(contest, contestant), data: { turbo_method: :delete }, class: "btn btn-danger me-2"
|
||||
= link_to t("helpers.buttons.delete"), contest_contestant_path(contest, contestant), data: { turbo_method: :delete }, class: "btn btn-danger me-2"
|
||||
= form.submit submit_text, class: "btn btn-primary"
|
||||
|
||||
- if method == :patch
|
||||
@ -27,27 +28,35 @@
|
||||
table.table.table-striped.table-hover
|
||||
thead
|
||||
tr
|
||||
- if @contest.puzzles.size > 1
|
||||
th scope="col"
|
||||
= t("activerecord.attributes.completion.display_time_from_start")
|
||||
th scope="col"
|
||||
= t("activerecord.attributes.completion.display_relative_time")
|
||||
- else
|
||||
th scope="col"
|
||||
= t("activerecord.attributes.completion.display_time")
|
||||
th scope="col"
|
||||
| Time since start
|
||||
th scope="col"
|
||||
| Relative time
|
||||
th scope="col"
|
||||
| Puzzle
|
||||
= t("activerecord.attributes.completion.puzzle")
|
||||
tbody
|
||||
- @completions.each do |completion|
|
||||
tr scope="row"
|
||||
td
|
||||
= completion.display_time_from_start
|
||||
= completion.display_time_from_start
|
||||
- if @contest.puzzles.size > 1
|
||||
td
|
||||
= completion.display_relative_time
|
||||
td
|
||||
= completion.display_relative_time
|
||||
td
|
||||
| #{completion.puzzle.name} - #{completion.puzzle.brand}
|
||||
- if !completion.puzzle.brand.blank?
|
||||
| #{completion.puzzle.name} - #{completion.puzzle.brand}
|
||||
- else
|
||||
| #{completion.puzzle.name}
|
||||
td
|
||||
a.btn.btn-sm.btn-secondary.me-2 href=edit_contest_completion_path(@contest, completion, contestant_id: contestant.id)
|
||||
| Edit
|
||||
= link_to "Delete", contest_completion_path(contest, completion, contestant_id: contestant.id),
|
||||
= t("helpers.buttons.edit")
|
||||
= link_to t("helpers.buttons.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)
|
||||
| Add completion
|
||||
= t("helpers.buttons.add")
|
||||
|
@ -26,7 +26,7 @@
|
||||
- @content[0].each_with_index do |_, i|
|
||||
th scope="col"
|
||||
= t("helpers.field") + "_#{i}"
|
||||
th scope="col"
|
||||
th scope="col" style="white-space: nowrap"
|
||||
= t("contestants.import.import_column")
|
||||
tbody
|
||||
- @content.each_with_index do |row, i|
|
||||
|
@ -1 +1 @@
|
||||
= render "form", contest: @contest, contestant: @contestant, submit_text: "Save", method: :patch, url: "/contests/#{@contest.id}/contestants/#{@contestant.id}"
|
||||
= render "form", contest: @contest, contestant: @contestant, submit_text: t("helpers.buttons.save"), method: :patch, url: "/contests/#{@contest.id}/contestants/#{@contestant.id}"
|
@ -1 +1 @@
|
||||
= render "form", contest: @contest, contestant: @contestant, submit_text: "Add", method: :post, url: "/contests/#{@contest.id}/contestants"
|
||||
= render "form", contest: @contest, contestant: @contestant, submit_text: t("helpers.buttons.add"), method: :post, url: "/contests/#{@contest.id}/contestants"
|
@ -103,7 +103,7 @@
|
||||
thead
|
||||
tr
|
||||
th scope="col"
|
||||
| Rank
|
||||
= t("helpers.rank")
|
||||
th scope="col"
|
||||
= t("activerecord.attributes.contestant.name")
|
||||
th scope="col"
|
||||
|
@ -38,6 +38,12 @@ en:
|
||||
greater_than: "Participant names are required"
|
||||
activerecord:
|
||||
attributes:
|
||||
completion:
|
||||
contestant: Participant
|
||||
display_time: Time
|
||||
display_time_from_start: Time since start
|
||||
display_relative_time: Time for this puzzle
|
||||
puzzle: Puzzle
|
||||
contest:
|
||||
name: "Name"
|
||||
team: "Team contest"
|
||||
@ -45,7 +51,14 @@ en:
|
||||
allow_registration: "Allow registration"
|
||||
allow_registration_description: "Generates a shareable registration form for this contest"
|
||||
contestant:
|
||||
completions: completions
|
||||
display_time: Time
|
||||
email: "Email"
|
||||
name: "Name"
|
||||
email_description: "Optional. Used for sending emails through this app, or for identifying participants whose gmeet handle doesn't match their registered name."
|
||||
csv_import:
|
||||
file: File
|
||||
separator: Separator
|
||||
message:
|
||||
author: "Author"
|
||||
processed: "Processed?"
|
||||
@ -65,15 +78,28 @@ en:
|
||||
completion:
|
||||
attributes:
|
||||
display_time_from_start:
|
||||
blank: Mandatory
|
||||
invalid: "Allowed formats: xx:xx:xx, x:xx:xx, xx:xx, x:xx, xx"
|
||||
puzzle_id:
|
||||
taken: "This contestant has already completed this puzzle"
|
||||
contest:
|
||||
attributes:
|
||||
name:
|
||||
blank: The contest name cannot be empty
|
||||
contestant:
|
||||
attributes:
|
||||
name:
|
||||
blank: The participant name cannot be empty
|
||||
csv_import:
|
||||
attributes:
|
||||
file:
|
||||
blank: "No file selected"
|
||||
empty: "This file is empty"
|
||||
not_a_csv_file: "it must be a CSV file"
|
||||
puzzle:
|
||||
attributes:
|
||||
name:
|
||||
blank: The puzzle name cannot be empty
|
||||
completions:
|
||||
edit:
|
||||
title: "Edit completion"
|
||||
@ -132,9 +158,12 @@ en:
|
||||
create: "Create"
|
||||
delete: "Delete"
|
||||
edit: "Edit"
|
||||
import: "CSV Import"
|
||||
save: "Save"
|
||||
field: "Field"
|
||||
import: CSV Import
|
||||
open: Open
|
||||
save: Save
|
||||
field: Field
|
||||
none: No field selected
|
||||
rank: Rank
|
||||
messages:
|
||||
convert:
|
||||
title: "New completion"
|
||||
|
@ -9,6 +9,12 @@ fr:
|
||||
greater_than: "Choisir une colonne pour les noms des participant.e.s est nécessaire"
|
||||
activerecord:
|
||||
attributes:
|
||||
completion:
|
||||
contestant_id: Participant.e
|
||||
display_time: Temps
|
||||
display_time_from_start: Temps depuis le début
|
||||
display_relative_time: Temps pour ce puzzle
|
||||
puzzle: Puzzle
|
||||
contest:
|
||||
name: "Nom"
|
||||
team: "Concours par équipes"
|
||||
@ -16,7 +22,14 @@ fr:
|
||||
allow_registration: "Autoriser l'inscription via l'interface"
|
||||
allow_registration_description: "Génère un formulaire d'inscription pour ce concours"
|
||||
contestant:
|
||||
completions: Complétions
|
||||
display_time: Temps
|
||||
email: "Email"
|
||||
name: "Nom"
|
||||
email_description: "Optionnel. Utile pour envoyer des emails aux participant.e.s depuis cette app, ou pour reconnaître les pseudos gmeet quand ils ne correspondent pas au nom préalablement entré."
|
||||
csv_import:
|
||||
file: Fichier
|
||||
separator: Délimiteur
|
||||
message:
|
||||
author: "Auteur.ice"
|
||||
processed: "Traité ?"
|
||||
@ -36,15 +49,28 @@ fr:
|
||||
completion:
|
||||
attributes:
|
||||
display_time_from_start:
|
||||
blank: Obligatoire
|
||||
invalid: "Formats autorisés: xx:xx:xx, x:xx:xx, xx:xx, x:xx, xx"
|
||||
puzzle_id:
|
||||
taken: "Ce.tte participant.e a déjà complété ce puzzle"
|
||||
contest:
|
||||
attributes:
|
||||
name:
|
||||
blank: Le nom du concours ne peut pas être vide
|
||||
contestant:
|
||||
attributes:
|
||||
name:
|
||||
blank: Le nom du ou de la participant.e ne peut pas être vide
|
||||
csv_import:
|
||||
attributes:
|
||||
file:
|
||||
blank: "Aucun fichier sélectionné"
|
||||
empty: "Ce fichier est vide"
|
||||
not_a_csv_file: "Le fichier doit être au format CSV"
|
||||
puzzle:
|
||||
attributes:
|
||||
name:
|
||||
blank: Le nom du puzzle est obligatoire
|
||||
completions:
|
||||
edit:
|
||||
title: "Modifier la complétion"
|
||||
@ -103,9 +129,12 @@ fr:
|
||||
create: "Créer"
|
||||
delete: "Supprimer"
|
||||
edit: "Modifier"
|
||||
import: "Importer un CSV"
|
||||
save: "Modifier"
|
||||
field: "Champ"
|
||||
import: Importer un CSV
|
||||
open: Détails
|
||||
save: Modifier
|
||||
field: Champ
|
||||
none: Aucun champ sélectionné
|
||||
rank: Rang
|
||||
messages:
|
||||
convert:
|
||||
title: "Ajout d'une complétion"
|
||||
|
Loading…
x
Reference in New Issue
Block a user