Results tab ok

This commit is contained in:
Claude Brisson
2023-12-24 07:45:26 +01:00
parent 36f9fe6f09
commit 864ba82b57
7 changed files with 74 additions and 7 deletions

View File

@@ -33,6 +33,7 @@ object PairingHandler: PairgothApiHandler {
override fun post(request: HttpServletRequest): Json {
val tournament = getTournament(request)
val round = getSubSelector(request)?.toIntOrNull() ?: badRequest("invalid round number")
if (round > tournament.lastRound() + 1) badRequest("invalid round: previous round has not been played")
val payload = getArrayPayload(request)
val allPlayers = payload.size == 1 && payload[0] == "all"
//if (!allPlayers && tournament.pairing.type == PairingType.SWISS) badRequest("Swiss pairing requires all pairable players")

View File

@@ -21,6 +21,7 @@ object ResultsHandler: PairgothApiHandler {
override fun put(request: HttpServletRequest): Json {
val tournament = getTournament(request)
val round = getSubSelector(request)?.toIntOrNull() ?: badRequest("invalid round number")
if (round != tournament.lastRound()) badRequest("cannot enter results in other rounds but the last")
val payload = getObjectPayload(request)
val game = tournament.games(round)[payload.getInt("id")] ?: badRequest("invalid game id")
game.result = Game.Result.fromSymbol(payload.getChar("result") ?: badRequest("missing result"))

View File

@@ -212,6 +212,7 @@ object OpenGotha {
}
</Players>
<Games>
// TODO - table number is not any more kinda random like this
${(1..tournament.lastRound()).map { tournament.games(it) }.flatMapIndexed { index, games ->
games.values.mapIndexed { table, game ->
Triple(index + 1, table , game)