Worlds: stop bets at midnight before the start of the competition
This commit is contained in:
@@ -66,6 +66,9 @@ class WorldsController < ApplicationController
|
||||
def create
|
||||
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.score = 0
|
||||
|
||||
@@ -1,48 +1,52 @@
|
||||
= render "worlds_nav"
|
||||
|
||||
.alert.alert-warning role="alert"
|
||||
= t("worlds.about.one_bet_message")
|
||||
- if DateTime.now > Time.new(2026, 9, 16, 23, 59, 59, "+02:00")
|
||||
.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|
|
||||
.alert.alert-primary role="alert"
|
||||
= t("worlds.new.message")
|
||||
|
||||
.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
|
||||
= form_with model: @world_bet, url: "/wjpc_bets/#{@lang}/new", method: :post do |form|
|
||||
.alert.alert-primary role="alert"
|
||||
= t("worlds.new.message")
|
||||
|
||||
.row.mt-4
|
||||
.col
|
||||
.input-group
|
||||
.input-group-text ##{i} <i class="ms-2" style="color: cadetblue;">(x#{WorldBet.multiplier(i - 1)})</i>
|
||||
= form.select "w_bet_#{i}", @world_participants.map { |p| [Flags.get_flag(p.world_country.code) + " " + p.name, p.id] }, {}, class: "form-select"
|
||||
.form-floating
|
||||
= form.text_field :name, autocomplete: "off", class: "form-control"
|
||||
= form.label :name, class: "required"
|
||||
|
||||
.row.mt-4
|
||||
.col
|
||||
h4 = t("worlds.new.french_section")
|
||||
|
||||
- (1..10).each do |i|
|
||||
.row.mt-3
|
||||
.row.mt-4
|
||||
.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"
|
||||
h4 = t("worlds.new.world_section")
|
||||
|
||||
- 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-3
|
||||
.col
|
||||
.input-group
|
||||
.input-group-text ##{i} <i class="ms-2" style="color: cadetblue;">(x#{WorldBet.multiplier(i - 1)})</i>
|
||||
= 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
|
||||
.col
|
||||
= form.submit t("helpers.buttons.validate"), class: "btn btn-primary"
|
||||
.row.mt-4
|
||||
.col
|
||||
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"
|
||||
@@ -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 ;)
|
||||
notice: The bet has been made!
|
||||
tab: Make a bet!
|
||||
too_late_message: Bets are now closed!
|
||||
world_section: Bet over all participants
|
||||
title: WJPC bets
|
||||
view:
|
||||
|
||||
@@ -439,6 +439,7 @@ fr:
|
||||
notice: Le pari est enregistré !
|
||||
tab: Fais ton pari !
|
||||
title: Nouveau pari
|
||||
too_late_message: Les paris sont désormais fermés !
|
||||
world_section: Pari sur l'ensemble des participant.e.s
|
||||
title: Les paris des WJPC
|
||||
view:
|
||||
|
||||
Reference in New Issue
Block a user