Fix pairgoth import and EGF/FFG export missing flush

This commit is contained in:
Claude Brisson
2024-03-07 05:43:45 +01:00
parent 418aad891d
commit e4eff46750
4 changed files with 12 additions and 6 deletions

View File

@@ -92,11 +92,13 @@ object StandingsHandler: PairgothApiHandler {
val neededCriteria = ArrayList(tournament.pairing.placementParams.criteria)
if (!neededCriteria.contains(NBW)) neededCriteria.add(NBW)
exportToEGFFormat(tournament, sortedPairables, neededCriteria, writer)
writer.flush()
return null
}
"application/ffg" -> {
response.contentType = "text/plain;charset=${encoding}"
exportToFFGFormat(tournament, sortedPairables, writer)
writer.flush()
return null
}
else -> ApiHandler.badRequest("invalid Accept header: $accept")

View File

@@ -27,7 +27,9 @@ class ImportServlet: HttpServlet() {
if (json == null || !json.isObject) {
resp.sendError(HttpServletResponse.SC_BAD_REQUEST)
} else {
apiResp = api.post("tour", json.asObject())
val filtered = Json.MutableObject(json.asObject())
filtered.remove("id")
apiResp = api.post("tour", filtered)
}
}
else { // xml ?
@@ -55,8 +57,10 @@ class ImportServlet: HttpServlet() {
if (example == null || !example.isObject) {
response.sendError(HttpServletResponse.SC_BAD_REQUEST)
} else {
val filtered = Json.MutableObject(example.asObject())
filtered.remove("id")
val api = ApiTool().apply { setRequest(request) }
val apiResp = api.post("tour", example)
val apiResp = api.post("tour", filtered)
if (apiResp.isObject && apiResp.asObject().getBoolean("success") == true) {
response.contentType = "application/json; charset=UTF-8"
response.writer.println(apiResp.toString())

View File

@@ -78,7 +78,7 @@ Nbw NbV
New Tournament Nouveau Tournoi
New tournament Nouveau tournoi
Next rounds seeding Méthode rondes suivantes
OpenGotha file Fichier OpenGotha
OpenGotha / Pairgoth file Fichier OpenGotha / Pairgoth
Pair Apparier
Pair-go tournament Tournoi de pair-go
Pairing Appariements

View File

@@ -39,8 +39,8 @@
<form id="import-form" class="ui form">
<div class="popup-content">
<div class="field">
<label>OpenGotha file</label>
<input type="file" name="file" accept=".xml"/>
<label>OpenGotha / Pairgoth file</label>
<input type="file" name="file" accept=".tour,.xml"/>
</div>
</div>
<div class="popup-footer">