From c1f7518f5c5267c312a03d00e896e72477b4aedd Mon Sep 17 00:00:00 2001 From: jmpla Date: Sun, 3 Dec 2023 00:17:16 +0100 Subject: [PATCH 1/3] ajout export fichier par NIP --- app/scodoc/sco_excel.py | 11 +++++++++++ app/scodoc/sco_saisie_notes.py | 3 +-- 2 files changed, 12 insertions(+), 2 deletions(-) diff --git a/app/scodoc/sco_excel.py b/app/scodoc/sco_excel.py index 87debfaa..df86e924 100644 --- a/app/scodoc/sco_excel.py +++ b/app/scodoc/sco_excel.py @@ -283,6 +283,13 @@ class ScoExcelSheet: """ self.ws.row_dimensions[cle].hidden = value + def set_column_dimension_hidden(self, cle, value): + """Masque ou affiche une ligne. + cle -- identifie la colonne (1...) + value -- boolean (vrai = colonne cachée) + """ + self.ws.column_dimensions[cle].hidden = value + def make_cell(self, value: any = None, style=None, comment=None): """Construit une cellule. value -- contenu de la cellule (texte, numérique, booléen ou date) @@ -450,6 +457,8 @@ def excel_feuille_saisie(evaluation: "Evaluation", titreannee, description, line ws.set_column_dimension_width("D", 164.0 / 7) # groupes ws.set_column_dimension_width("E", 115.0 / 7) # notes ws.set_column_dimension_width("F", 355.0 / 7) # remarques + ws.set_column_dimension_width("G", 11.0 / 7) # colonne NIP + ws.set_column_dimension_hidden("G", True) # colonne NIP cachée # fontes font_base = Font(name="Arial", size=12) @@ -526,6 +535,7 @@ def excel_feuille_saisie(evaluation: "Evaluation", titreannee, description, line ws.make_cell("Groupe", style_titres), ws.make_cell("Note sur %g" % (evaluation.note_max or 0.0), style_titres), ws.make_cell("Remarque", style_titres), + ws.make_cell("NIP", style_titres), ] ) @@ -552,6 +562,7 @@ def excel_feuille_saisie(evaluation: "Evaluation", titreannee, description, line ws.make_cell(s, st), ws.make_cell(val, style_notes), # note ws.make_cell(line[6], style_comment), # comment + ws.make_cell(line[7], style_ro), # NIP ] ) diff --git a/app/scodoc/sco_saisie_notes.py b/app/scodoc/sco_saisie_notes.py index 87bc1097..993055e1 100644 --- a/app/scodoc/sco_saisie_notes.py +++ b/app/scodoc/sco_saisie_notes.py @@ -922,13 +922,11 @@ def feuille_saisie_notes(evaluation_id, group_ids=[]): # une liste de liste de chaines: lignes de la feuille de calcul rows = [] - etuds = _get_sorted_etuds(evaluation, etudids, formsemestre.id) for e in etuds: etudid = e["etudid"] groups = sco_groups.get_etud_groups(etudid, formsemestre.id) grc = sco_groups.listgroups_abbrev(groups) - rows.append( [ str(etudid), @@ -938,6 +936,7 @@ def feuille_saisie_notes(evaluation_id, group_ids=[]): grc, e["val"], e["explanation"], + e["code_nip"], ] ) From f1bb5ffa9c042fa2e73e72dbf01dcbbfa61fcba0 Mon Sep 17 00:00:00 2001 From: jmpla Date: Sun, 3 Dec 2023 15:19:35 +0100 Subject: [PATCH 2/3] add_filter --- app/scodoc/sco_excel.py | 16 ++++++++++++++++ 1 file changed, 16 insertions(+) diff --git a/app/scodoc/sco_excel.py b/app/scodoc/sco_excel.py index df86e924..ba76a5e9 100644 --- a/app/scodoc/sco_excel.py +++ b/app/scodoc/sco_excel.py @@ -218,6 +218,7 @@ class ScoExcelSheet: self.rows = [] # list of list of cells self.column_dimensions = {} self.row_dimensions = {} + self.auto_filter = None def excel_make_composite_style( self, @@ -290,6 +291,9 @@ class ScoExcelSheet: """ self.ws.column_dimensions[cle].hidden = value + def set_auto_filter(self, range): + self.auto_filter = range + def make_cell(self, value: any = None, style=None, comment=None): """Construit une cellule. value -- contenu de la cellule (texte, numérique, booléen ou date) @@ -390,6 +394,8 @@ class ScoExcelSheet: # construction d'un flux (https://openpyxl.readthedocs.io/en/stable/tutorial.html#saving-as-a-stream) self.prepare() + if self.auto_filter is not None: + self.ws.auto_filter.ref = self.auto_filter with NamedTemporaryFile() as tmp: self.wb.save(tmp.name) tmp.seek(0) @@ -507,6 +513,13 @@ def excel_feuille_saisie(evaluation: "Evaluation", titreannee, description, line "border": border_top, } + # filtre + filter_top = 8 + filter_bottom = 8 + len(lines) + filter_left = "A" + filter_right = "G" + ws.set_auto_filter(f"${filter_left}${filter_top}:${filter_right}${filter_bottom}") + # ligne de titres ws.append_single_cell_row( "Feuille saisie note (à enregistrer au format excel)", style_titres @@ -566,6 +579,9 @@ def excel_feuille_saisie(evaluation: "Evaluation", titreannee, description, line ] ) + # ligne blanche + ws.append_blank_row() + # explication en bas ws.append_row([None, ws.make_cell("Code notes", style_titres)]) ws.append_row( From 4d07de20d51f2e70628efdd1acc1e48dac88284b Mon Sep 17 00:00:00 2001 From: Emmanuel Viennet Date: Sun, 3 Dec 2023 16:04:32 +0100 Subject: [PATCH 3/3] adjust NIP colum width --- app/scodoc/sco_excel.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/app/scodoc/sco_excel.py b/app/scodoc/sco_excel.py index ba76a5e9..a336fa1a 100644 --- a/app/scodoc/sco_excel.py +++ b/app/scodoc/sco_excel.py @@ -463,7 +463,7 @@ def excel_feuille_saisie(evaluation: "Evaluation", titreannee, description, line ws.set_column_dimension_width("D", 164.0 / 7) # groupes ws.set_column_dimension_width("E", 115.0 / 7) # notes ws.set_column_dimension_width("F", 355.0 / 7) # remarques - ws.set_column_dimension_width("G", 11.0 / 7) # colonne NIP + ws.set_column_dimension_width("G", 72.0 / 7) # colonne NIP ws.set_column_dimension_hidden("G", True) # colonne NIP cachée # fontes