From ecaef644b36e9632c4682ef9ef3082093d79cf6d Mon Sep 17 00:00:00 2001 From: imperosol Date: Tue, 8 Sep 2026 23:49:04 +0200 Subject: [PATCH] show the broken line on timetable parsing error MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Certains utilisateurs font remonter régulièrement que le générateur ne marche pas. C'est normal, on n'a pas forcément prévu tous les cas et on n'est pas à l'abri des changements de format de l'UTBM. Ce qui est très embêtant, dans ces cas-là, c'est qu'on donne très peu d'informations sur ce qui n'a pas marché, et que les utilisateurs peuvent difficilement faire remonter plus que ça. En décrivant la ligne qui n'a pas pu être parsée, ça devrait déjà rendre la gestion de ce genre de problème un peu plus facile, tout en étant plus transparent pour l'utilisateur --- locale/fr/LC_MESSAGES/django.po | 13 +++++++++++- locale/fr/LC_MESSAGES/djangojs.po | 12 +++-------- .../bundled/timetable/generator-index.ts | 11 +++++----- timetable/templates/timetable/generator.jinja | 20 ++++++++++++++++--- 4 files changed, 37 insertions(+), 19 deletions(-) diff --git a/locale/fr/LC_MESSAGES/django.po b/locale/fr/LC_MESSAGES/django.po index 4bc80079..3bd7ea07 100644 --- a/locale/fr/LC_MESSAGES/django.po +++ b/locale/fr/LC_MESSAGES/django.po @@ -6,7 +6,7 @@ msgid "" msgstr "" "Report-Msgid-Bugs-To: \n" -"POT-Creation-Date: 2026-09-04 11:24+0200\n" +"POT-Creation-Date: 2026-09-08 23:36+0200\n" "PO-Revision-Date: 2016-07-18\n" "Last-Translator: Maréchal \n" @@ -5852,6 +5852,17 @@ msgstr "les groupes pouvant créer des cotisations" msgid "Timetable generator" msgstr "Générateur d'emploi du temps" +#: timetable/templates/timetable/generator.jinja +msgid "" +"Wrong timetable format. Make sure you copied if from your student folder." +msgstr "" +"Mauvais format d'emploi du temps. Assurez-vous que vous l'avez copié depuis " +"votre dossier étudiant." + +#: timetable/templates/timetable/generator.jinja +msgid "Incorrect row" +msgstr "Ligne incorrecte" + #: timetable/templates/timetable/generator.jinja msgid "Generate" msgstr "Générer" diff --git a/locale/fr/LC_MESSAGES/djangojs.po b/locale/fr/LC_MESSAGES/djangojs.po index 33d24897..6a607daf 100644 --- a/locale/fr/LC_MESSAGES/djangojs.po +++ b/locale/fr/LC_MESSAGES/djangojs.po @@ -7,7 +7,7 @@ msgid "" msgstr "" "Report-Msgid-Bugs-To: \n" -"POT-Creation-Date: 2026-05-17 10:03+0200\n" +"POT-Creation-Date: 2026-09-08 23:36+0200\n" "PO-Revision-Date: 2024-09-17 11:54+0200\n" "Last-Translator: Sli \n" "Language-Team: AE info \n" @@ -22,8 +22,8 @@ msgid "" "You're going to remove your own role from the presidency. You may lock " "yourself out of this page. Do you want to continue ? " msgstr "" -"Vous vous apprêtez à retirer votre propre rôle de la présidence. Vous risquez " -"de perdre l'accès à cette page. Voulez-vous continuer ?" +"Vous vous apprêtez à retirer votre propre rôle de la présidence. Vous " +"risquez de perdre l'accès à cette page. Voulez-vous continuer ?" #: com/static/bundled/com/components/ics-calendar-index.ts msgid "More info" @@ -279,9 +279,3 @@ msgstr "Il n'a pas été possible de modérer l'image" msgid "Couldn't delete picture" msgstr "Il n'a pas été possible de supprimer l'image" -#: timetable/static/bundled/timetable/generator-index.ts -msgid "" -"Wrong timetable format. Make sure you copied if from your student folder." -msgstr "" -"Mauvais format d'emploi du temps. Assurez-vous que vous l'avez copié depuis " -"votre dossier étudiant." diff --git a/timetable/static/bundled/timetable/generator-index.ts b/timetable/static/bundled/timetable/generator-index.ts index 4b55401b..51438094 100644 --- a/timetable/static/bundled/timetable/generator-index.ts +++ b/timetable/static/bundled/timetable/generator-index.ts @@ -59,7 +59,7 @@ function parseSlots(s: string): TimetableSlot[] { .map((row: string) => { const parsed = TIMETABLE_ROW_RE.exec(row); if (!parsed?.groups) { - throw new Error(`Couldn't parse row ${row}`); + throw new Error(`Couldn't parse row ${row}`, { cause: { row: row } }); } const [startHour, startMin] = parsed.groups.startHour .split(":") @@ -78,7 +78,7 @@ function parseSlots(s: string): TimetableSlot[] { document.addEventListener("alpine:init", () => { Alpine.data("timetableGenerator", () => ({ content: DEFAULT_TIMETABLE, - error: "", + error: null as { incorrectRow?: string }, displayedWeekdays: [] as WeekDay[], courses: [] as TimetableSlot[], startSlot: 0, @@ -106,10 +106,9 @@ document.addEventListener("alpine:init", () => { generate() { try { this.courses = parseSlots(this.content); - } catch { - this.error = gettext( - "Wrong timetable format. Make sure you copied if from your student folder.", - ); + this.error = null; + } catch (err) { + this.error = { incorrectRow: err?.cause?.row }; return; } diff --git a/timetable/templates/timetable/generator.jinja b/timetable/templates/timetable/generator.jinja index bbbc52b7..1d97ee6e 100644 --- a/timetable/templates/timetable/generator.jinja +++ b/timetable/templates/timetable/generator.jinja @@ -16,9 +16,23 @@

Générateur d'emploi du temps

-
- -
+