From a3cccac2d2996a3ebb8f36f88f70fae226acd2b6 Mon Sep 17 00:00:00 2001 From: Emmanuel Viennet Date: Thu, 9 Jun 2022 14:01:47 +0200 Subject: [PATCH] Liste saisies de notes: formattage des valeurs --- app/scodoc/sco_undo_notes.py | 8 ++++++-- app/scodoc/sco_utils.py | 3 +++ 2 files changed, 9 insertions(+), 2 deletions(-) diff --git a/app/scodoc/sco_undo_notes.py b/app/scodoc/sco_undo_notes.py index 5cff6fe4..4743ca6c 100644 --- a/app/scodoc/sco_undo_notes.py +++ b/app/scodoc/sco_undo_notes.py @@ -180,7 +180,7 @@ def formsemestre_list_saisies_notes(formsemestre_id, format="html"): les Ă©valuations du semestre. """ sem = sco_formsemestre.get_formsemestre(formsemestre_id, raise_soft_exc=True) - r = ndb.SimpleDictFetch( + rows = ndb.SimpleDictFetch( """SELECT i.nom, i.prenom, code_nip, n.*, mod.titre, e.description, e.jour, u.user_name, e.id as evaluation_id FROM notes_notes n, notes_evaluation e, notes_moduleimpl mi, notes_modules mod, identite i, "user" u @@ -194,6 +194,10 @@ def formsemestre_list_saisies_notes(formsemestre_id, format="html"): """, {"formsemestre_id": formsemestre_id}, ) + # Formatte les notes + keep_numeric = format in scu.FORMATS_NUMERIQUES + for row in rows: + row["value"] = scu.fmt_note(row["value"], keep_numeric=keep_numeric) columns_ids = ( "date", "code_nip", @@ -223,7 +227,7 @@ def formsemestre_list_saisies_notes(formsemestre_id, format="html"): tab = GenTable( titles=titles, columns_ids=columns_ids, - rows=r, + rows=rows, html_title="

Saisies de notes dans %s

" % sem["titreannee"], html_class="table_leftalign table_coldate gt_table_searchable", html_class_ignore_default=True, diff --git a/app/scodoc/sco_utils.py b/app/scodoc/sco_utils.py index 3449785b..924d59db 100644 --- a/app/scodoc/sco_utils.py +++ b/app/scodoc/sco_utils.py @@ -399,6 +399,9 @@ XLSX_SUFFIX = ".xlsx" XML_MIMETYPE = "text/xml" XML_SUFFIX = ".xml" +# Format pour lesquels on exporte sans formattage des nombres (pas de perte de précision) +FORMATS_NUMERIQUES = {"csv", "xls", "xlsx", "xml", "json"} + def get_mime_suffix(format_code: str) -> tuple[str, str]: """Returns (MIME, SUFFIX) from format_code == "xls", "xml", ...