Ignore validity of matching params if only playoff_teams_amount changed
If only playoff_teams_amount changed, the other two will be overwritten anyways.
This commit is contained in:
parent
6a060651a4
commit
b408d1dd37
|
|
@ -115,11 +115,20 @@ class TournamentsController < ApplicationController
|
||||||
render json: { error: 'Invalid teams array' }, status: :unprocessable_entity
|
render json: { error: 'Invalid teams array' }, status: :unprocessable_entity
|
||||||
end
|
end
|
||||||
|
|
||||||
|
def only_playoff_teams_amount_changed
|
||||||
|
params['playoff_teams_amount'] &&
|
||||||
|
params['instant_finalists_amount'].nil? &&
|
||||||
|
params['intermediate_round_participants_amount'].nil?
|
||||||
|
end
|
||||||
|
|
||||||
def validate_update_params
|
def validate_update_params
|
||||||
|
return if only_playoff_teams_amount_changed
|
||||||
|
|
||||||
playoff_teams_amount = params['playoff_teams_amount'] || @tournament.playoff_teams_amount
|
playoff_teams_amount = params['playoff_teams_amount'] || @tournament.playoff_teams_amount
|
||||||
instant_finalists_amount = params['instant_finalists_amount'] || @tournament.instant_finalists_amount
|
instant_finalists_amount = params['instant_finalists_amount'] || @tournament.instant_finalists_amount
|
||||||
intermediate_round_participants_amount = params['intermediate_round_participants_amount'] ||
|
intermediate_round_participants_amount = params['intermediate_round_participants_amount'] ||
|
||||||
@tournament.intermediate_round_participants_amount
|
@tournament.intermediate_round_participants_amount
|
||||||
|
|
||||||
return if instant_finalists_amount + (intermediate_round_participants_amount / 2) ==
|
return if instant_finalists_amount + (intermediate_round_participants_amount / 2) ==
|
||||||
playoff_teams_amount
|
playoff_teams_amount
|
||||||
|
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue