Final reg status handling tweaks
This commit is contained in:
@@ -21,8 +21,8 @@ object PairingHandler: PairgothApiHandler {
|
|||||||
val playing = tournament.games(round).values.flatMap {
|
val playing = tournament.games(round).values.flatMap {
|
||||||
listOf(it.black, it.white)
|
listOf(it.black, it.white)
|
||||||
}.toSet()
|
}.toSet()
|
||||||
val unpairables = tournament.pairables.values.filter { it.skip.contains(round) }.sortedByDescending { it.rating }.map { it.id }.toJsonArray()
|
val unpairables = tournament.pairables.values.filter { !it.final || it.skip.contains(round) }.sortedByDescending { it.rating }.map { it.id }.toJsonArray()
|
||||||
val pairables = tournament.pairables.values.filter { !it.skip.contains(round) && !playing.contains(it.id) }.sortedByDescending { it.rating }.map { it.id }.toJsonArray()
|
val pairables = tournament.pairables.values.filter { it.final && !it.skip.contains(round) && !playing.contains(it.id) }.sortedByDescending { it.rating }.map { it.id }.toJsonArray()
|
||||||
val games = tournament.games(round).values
|
val games = tournament.games(round).values
|
||||||
return Json.Object(
|
return Json.Object(
|
||||||
"games" to games.map { it.toJson() }.toCollection(Json.MutableArray()),
|
"games" to games.map { it.toJson() }.toCollection(Json.MutableArray()),
|
||||||
@@ -44,12 +44,13 @@ object PairingHandler: PairgothApiHandler {
|
|||||||
}.toSet()
|
}.toSet()
|
||||||
val pairables =
|
val pairables =
|
||||||
if (allPlayers)
|
if (allPlayers)
|
||||||
tournament.pairables.values.filter { !it.skip.contains(round) && !playing.contains(it.id) }
|
tournament.pairables.values.filter { it.final && !it.skip.contains(round) && !playing.contains(it.id) }
|
||||||
else payload.map {
|
else payload.map {
|
||||||
// CB - because of the '["all"]' map, conversion to int lands here... Better API syntax for 'all players'?
|
// CB - because of the '["all"]' map, conversion to int lands here... Better API syntax for 'all players'?
|
||||||
if (it is Number) it.toID() else badRequest("invalid pairable id: #$it")
|
if (it is Number) it.toID() else badRequest("invalid pairable id: #$it")
|
||||||
}.map { id ->
|
}.map { id ->
|
||||||
tournament.pairables[id]?.also {
|
tournament.pairables[id]?.also {
|
||||||
|
if (!it.final) badRequest("pairable #$id registration status is not final")
|
||||||
if (it.skip.contains(round)) badRequest("pairable #$id does not play round $round")
|
if (it.skip.contains(round)) badRequest("pairable #$id does not play round $round")
|
||||||
if (playing.contains(it.id)) badRequest("pairable #$id already plays round $round")
|
if (playing.contains(it.id)) badRequest("pairable #$id already plays round $round")
|
||||||
} ?: badRequest("invalid pairable id: #$id")
|
} ?: badRequest("invalid pairable id: #$id")
|
||||||
@@ -79,6 +80,8 @@ object PairingHandler: PairgothApiHandler {
|
|||||||
payload.getInt("dudd")?.let { game.drawnUpDown = it }
|
payload.getInt("dudd")?.let { game.drawnUpDown = it }
|
||||||
val black = tournament.pairables[game.black] ?: badRequest("invalid black player id")
|
val black = tournament.pairables[game.black] ?: badRequest("invalid black player id")
|
||||||
val white = tournament.pairables[game.black] ?: badRequest("invalid white player id")
|
val white = tournament.pairables[game.black] ?: badRequest("invalid white player id")
|
||||||
|
if (!black.final) badRequest("black registration status is not final")
|
||||||
|
if (!white.final) badRequest("white registration status is not final")
|
||||||
if (black.skip.contains(round)) badRequest("black is not playing this round")
|
if (black.skip.contains(round)) badRequest("black is not playing this round")
|
||||||
if (white.skip.contains(round)) badRequest("white is not playing this round")
|
if (white.skip.contains(round)) badRequest("white is not playing this round")
|
||||||
if (playing.contains(black.id)) badRequest("black is already in another game")
|
if (playing.contains(black.id)) badRequest("black is already in another game")
|
||||||
|
@@ -288,6 +288,8 @@ onLoad(() => {
|
|||||||
}).then(player => {
|
}).then(player => {
|
||||||
if (player !== 'error') {
|
if (player !== 'error') {
|
||||||
cell.toggleClass('final');
|
cell.toggleClass('final');
|
||||||
|
standingsUpToDate = false;
|
||||||
|
pairablesUpToDate = false;
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
e.preventDefault();
|
e.preventDefault();
|
||||||
|
@@ -74,6 +74,7 @@
|
|||||||
const tour_rounds = ${tour.rounds};
|
const tour_rounds = ${tour.rounds};
|
||||||
let activeRound = ${round};
|
let activeRound = ${round};
|
||||||
let standingsUpToDate = true;
|
let standingsUpToDate = true;
|
||||||
|
let pairablesUpToDate = true;
|
||||||
// $params
|
// $params
|
||||||
#end
|
#end
|
||||||
#set($datepickerLocale = $translate.datepickerLocale($request.lang, $request.loc))
|
#set($datepickerLocale = $translate.datepickerLocale($request.lang, $request.loc))
|
||||||
@@ -108,6 +109,8 @@
|
|||||||
window.location.hash = `#${step}`;
|
window.location.hash = `#${step}`;
|
||||||
if (step === 'standings' && !standingsUpToDate) {
|
if (step === 'standings' && !standingsUpToDate) {
|
||||||
window.location.reload();
|
window.location.reload();
|
||||||
|
} else if (step === 'pairing' && !pairablesUpToDate) {
|
||||||
|
window.location.reload();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Reference in New Issue
Block a user