From 3d755efa7ecbd259b54352b3a933c215d204886e Mon Sep 17 00:00:00 2001 From: Claude Brisson Date: Thu, 29 Aug 2024 13:56:00 +0200 Subject: [PATCH] Add config options to enable/disable and show/hide egf & ffg ratings; choose ffg defaults after tournament country --- doc/configuration.md | 32 +++++++++++++++++++ .../org/jeudego/pairgoth/view/PairgothTool.kt | 5 +++ .../main/webapp/tour-registration.inc.html | 32 +++++++++++++------ 3 files changed, 60 insertions(+), 9 deletions(-) diff --git a/doc/configuration.md b/doc/configuration.md index 3e88826..cecded0 100644 --- a/doc/configuration.md +++ b/doc/configuration.md @@ -85,3 +85,35 @@ Logging configuration. logger.level = info logger.format = [%level] %ip [%logger] %message ``` + +## ratings + +Ratings configuration. `` stands for `egf` or `ffg` in the following. + +### freeze ratings date + +If the following property is given: + +``` +ratings..file = ... +``` + +then the given ratings file will be used (it must use the Pairgoth ratings json format). If not, the corresponding ratings will be automatically downloaded and stored into `ratings/EGF-yyyymmdd.json` or `ratings/FFG-yyyymmdd.json`. + +The typical use case, for a big tournament lasting several days or a congress, is to let Pairgoth download the latest expected ratings, then to add this property to freeze the ratings at a specific date. + +### enable or disable ratings + +Whether to display the EGF or FFG ratings button in the Add Player popup: + +``` +ratings..enable = true | false +``` + +Whether to show the ratings player IDs on the registration page: + +``` +ratings..show = true | false +``` + +For a tournament in France, both are true for `ffg` by default, false otherwise. diff --git a/view-webapp/src/main/kotlin/org/jeudego/pairgoth/view/PairgothTool.kt b/view-webapp/src/main/kotlin/org/jeudego/pairgoth/view/PairgothTool.kt index d223089..8212e5f 100644 --- a/view-webapp/src/main/kotlin/org/jeudego/pairgoth/view/PairgothTool.kt +++ b/view-webapp/src/main/kotlin/org/jeudego/pairgoth/view/PairgothTool.kt @@ -2,6 +2,7 @@ package org.jeudego.pairgoth.view import com.republicate.kson.Json import org.jeudego.pairgoth.ratings.RatingsManager +import org.jeudego.pairgoth.web.WebappManager import java.nio.file.Files import java.nio.file.Path import java.nio.file.Paths @@ -110,4 +111,8 @@ class PairgothTool { }.toSet() return players.filter { p -> !teamed.contains(p.getLong("id")) } } + + // EGF ratings + fun displayRatings(ratings: String, country: String): Boolean = WebappManager.properties.getProperty("ratings.${ratings}.enable")?.toBoolean() ?: (ratings.lowercase() != "ffg") || country.lowercase() == "fr" + fun showRatings(ratings: String, country: String): Boolean = WebappManager.properties.getProperty("ratings.${ratings}.enable")?.toBoolean() ?: (ratings.lowercase() != "ffg") || country.lowercase() == "fr" } \ No newline at end of file diff --git a/view-webapp/src/main/webapp/tour-registration.inc.html b/view-webapp/src/main/webapp/tour-registration.inc.html index 53eb509..b1c7c21 100644 --- a/view-webapp/src/main/webapp/tour-registration.inc.html +++ b/view-webapp/src/main/webapp/tour-registration.inc.html @@ -53,11 +53,12 @@ First name Country Club -##if($tour.country == 'FR') -## FFG -##else +#if($utils.showRatings('egf', $tour.country.toLowerCase())) PIN -##end +#end +#if($utils.showRatings('ffg', $tour.country.toLowerCase())) + FFG +#end Rank ## TableSort bug which inverts specified sort... Rating @@ -77,10 +78,11 @@ $part.firstname $part.country.toUpperCase() $part.club - #if($tour.country == 'FR') + #if($utils.showRatings('egf', $tour.country.toLowerCase())) + $!part.egf + #end + #if($utils.showRatings('ffg', $tour.country.toLowerCase())) $!part.ffg - #else - $!part.egf #end ## display MMS correction on the screen, but not when printed #rank($part.rank)#if($part.mmsCorrection) (#if($part.mmsCorrection > 0)+#end$part.mmsCorrection)#end @@ -135,7 +137,15 @@ #end -
+#set($needleWidth = 12) +#if($utils.displayRatings('egf', $tour.country.toLowerCase())) + #set($needleWidth = $needleWidth - 2) +#end +#if($utils.displayRatings('ffg', $tour.country.toLowerCase())) + #set($needleWidth = $needleWidth - 2) +#end +#set($cssWidth = { 8: 'eight', 10: 'ten', 12: 'twelve' }) +
@@ -152,6 +162,7 @@
*# +#if($utils.displayRatings('egf', $tour.country.toLowerCase()))
@@ -161,6 +172,8 @@
+#end +#if($utils.displayRatings('ffg', $tour.country.toLowerCase()))
@@ -170,8 +183,9 @@
+#end
-
+