Change playoff transition relevant attributes of tournament on update
They are only updated when playoff_teams_amount changed alone
This commit is contained in:
parent
e936fd40b2
commit
5004dec39a
|
|
@ -64,10 +64,20 @@ class TournamentsController < ApplicationController
|
||||||
|
|
||||||
# PATCH/PUT /tournaments/1
|
# PATCH/PUT /tournaments/1
|
||||||
def update
|
def update
|
||||||
if @tournament.update(tournament_params)
|
Tournament.transaction do
|
||||||
render json: @tournament
|
if only_playoff_teams_amount_changed
|
||||||
else
|
@tournament.instant_finalists_amount, @tournament.intermediate_round_participants_amount =
|
||||||
render json: @tournament.errors, status: :unprocessable_entity
|
TournamentService.calculate_default_amount_of_teams_advancing(
|
||||||
|
params['playoff_teams_amount'].to_i,
|
||||||
|
@tournament.stages.find_by(level: -1).groups.size
|
||||||
|
)
|
||||||
|
end
|
||||||
|
if @tournament.update(tournament_params)
|
||||||
|
render json: @tournament
|
||||||
|
else
|
||||||
|
render json: @tournament.errors, status: :unprocessable_entity
|
||||||
|
raise ActiveRecord::Rollback
|
||||||
|
end
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue