Worlds: stop bets at midnight before the start of the competition
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
2026-09-12 08:48:59 +02:00
parent 0b025c828b
commit 3b433b8a9d
4 changed files with 48 additions and 39 deletions
+3
View File
@@ -66,6 +66,9 @@ class WorldsController < ApplicationController
def create def create
authorize :world_bet authorize :world_bet
if DateTime.now > Time.new(2026, 9, 16, 23, 59, 59, "+02:00")
redirect_to "/wjpc_bets/#{@lang}/new" and return
end
@world_bet = WorldBet.new(world_bet_params) @world_bet = WorldBet.new(world_bet_params)
@world_bet.score = 0 @world_bet.score = 0
+43 -39
View File
@@ -1,48 +1,52 @@
= render "worlds_nav" = render "worlds_nav"
.alert.alert-warning role="alert" - if DateTime.now > Time.new(2026, 9, 16, 23, 59, 59, "+02:00")
= t("worlds.about.one_bet_message") .alert.alert-warning role="alert"
= t("worlds.new.too_late_message")
- else
.alert.alert-warning role="alert"
= t("worlds.about.one_bet_message")
= form_with model: @world_bet, url: "/wjpc_bets/#{@lang}/new", method: :post do |form| = form_with model: @world_bet, url: "/wjpc_bets/#{@lang}/new", method: :post do |form|
.alert.alert-primary role="alert" .alert.alert-primary role="alert"
= t("worlds.new.message") = t("worlds.new.message")
.row.mt-4 .row.mt-4
.col
.form-floating
= form.text_field :name, autocomplete: "off", class: "form-control"
= form.label :name, class: "required"
.row.mt-4
.col
h4 = t("worlds.new.world_section")
- (1..10).each do |i|
.row.mt-3
.col .col
.input-group .form-floating
.input-group-text ##{i} <i class="ms-2" style="color: cadetblue;">(x#{WorldBet.multiplier(i - 1)})</i> = form.text_field :name, autocomplete: "off", class: "form-control"
= form.select "w_bet_#{i}", @world_participants.map { |p| [Flags.get_flag(p.world_country.code) + " " + p.name, p.id] }, {}, class: "form-select" = form.label :name, class: "required"
.row.mt-4 .row.mt-4
.col
h4 = t("worlds.new.french_section")
- (1..10).each do |i|
.row.mt-3
.col .col
.input-group h4 = t("worlds.new.world_section")
.input-group-text ##{i} <i class="ms-2" style="color: cadetblue;">(x#{WorldBet.multiplier(i - 1)})</i>
= form.select "f_bet_#{i}", @french_participants.map { |p| [Flags.get_flag(p.world_country.code) + " " + p.name, p.id] }, {}, class: "form-select"
- if @w_array && @f_array
- (1..10).each do |i| - (1..10).each do |i|
javascript: .row.mt-3
el = document.querySelector('select[name="world_bet[w_bet_#{i}]"]'); .col
el.value = "#{@w_array[i - 1]}" .input-group
el = document.querySelector('select[name="world_bet[f_bet_#{i}]"]'); .input-group-text ##{i} <i class="ms-2" style="color: cadetblue;">(x#{WorldBet.multiplier(i - 1)})</i>
el.value = "#{@f_array[i - 1]}" = form.select "w_bet_#{i}", @world_participants.map { |p| [Flags.get_flag(p.world_country.code) + " " + p.name, p.id] }, {}, class: "form-select"
.row.mt-4.mb-5 .row.mt-4
.col .col
= form.submit t("helpers.buttons.validate"), class: "btn btn-primary" h4 = t("worlds.new.french_section")
- (1..10).each do |i|
.row.mt-3
.col
.input-group
.input-group-text ##{i} <i class="ms-2" style="color: cadetblue;">(x#{WorldBet.multiplier(i - 1)})</i>
= form.select "f_bet_#{i}", @french_participants.map { |p| [Flags.get_flag(p.world_country.code) + " " + p.name, p.id] }, {}, class: "form-select"
- if @w_array && @f_array
- (1..10).each do |i|
javascript:
el = document.querySelector('select[name="world_bet[w_bet_#{i}]"]');
el.value = "#{@w_array[i - 1]}"
el = document.querySelector('select[name="world_bet[f_bet_#{i}]"]');
el.value = "#{@f_array[i - 1]}"
.row.mt-4.mb-5
.col
= form.submit t("helpers.buttons.validate"), class: "btn btn-primary"
+1
View File
@@ -466,6 +466,7 @@ en:
message: To make a bet, you have to provide two ordered lists of 10 participants, one among all participants, and the other one only among French participants. The order matters! A score multiplier will be applied to each selected contestant (in parenthesis below). You can't select a participant twice on a list, but of course you can totally put a French contestant in both lists ;) message: To make a bet, you have to provide two ordered lists of 10 participants, one among all participants, and the other one only among French participants. The order matters! A score multiplier will be applied to each selected contestant (in parenthesis below). You can't select a participant twice on a list, but of course you can totally put a French contestant in both lists ;)
notice: The bet has been made! notice: The bet has been made!
tab: Make a bet! tab: Make a bet!
too_late_message: Bets are now closed!
world_section: Bet over all participants world_section: Bet over all participants
title: WJPC bets title: WJPC bets
view: view:
+1
View File
@@ -439,6 +439,7 @@ fr:
notice: Le pari est enregistré ! notice: Le pari est enregistré !
tab: Fais ton pari ! tab: Fais ton pari !
title: Nouveau pari title: Nouveau pari
too_late_message: Les paris sont désormais fermés !
world_section: Pari sur l'ensemble des participant.e.s world_section: Pari sur l'ensemble des participant.e.s
title: Les paris des WJPC title: Les paris des WJPC
view: view: