forked from ScoDoc/ScoDoc
Merge branch 'prod' of https://scodoc.org/git/viennet/ScoDoc
This commit is contained in:
commit
cb86d8c8e2
@ -218,6 +218,7 @@ class ScoExcelSheet:
|
|||||||
self.rows = [] # list of list of cells
|
self.rows = [] # list of list of cells
|
||||||
self.column_dimensions = {}
|
self.column_dimensions = {}
|
||||||
self.row_dimensions = {}
|
self.row_dimensions = {}
|
||||||
|
self.auto_filter = None
|
||||||
|
|
||||||
def excel_make_composite_style(
|
def excel_make_composite_style(
|
||||||
self,
|
self,
|
||||||
@ -283,6 +284,16 @@ class ScoExcelSheet:
|
|||||||
"""
|
"""
|
||||||
self.ws.row_dimensions[cle].hidden = value
|
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 set_auto_filter(self, range):
|
||||||
|
self.auto_filter = range
|
||||||
|
|
||||||
def make_cell(self, value: any = None, style=None, comment=None):
|
def make_cell(self, value: any = None, style=None, comment=None):
|
||||||
"""Construit une cellule.
|
"""Construit une cellule.
|
||||||
value -- contenu de la cellule (texte, numérique, booléen ou date)
|
value -- contenu de la cellule (texte, numérique, booléen ou date)
|
||||||
@ -383,6 +394,8 @@ class ScoExcelSheet:
|
|||||||
|
|
||||||
# construction d'un flux (https://openpyxl.readthedocs.io/en/stable/tutorial.html#saving-as-a-stream)
|
# construction d'un flux (https://openpyxl.readthedocs.io/en/stable/tutorial.html#saving-as-a-stream)
|
||||||
self.prepare()
|
self.prepare()
|
||||||
|
if self.auto_filter is not None:
|
||||||
|
self.ws.auto_filter.ref = self.auto_filter
|
||||||
with NamedTemporaryFile() as tmp:
|
with NamedTemporaryFile() as tmp:
|
||||||
self.wb.save(tmp.name)
|
self.wb.save(tmp.name)
|
||||||
tmp.seek(0)
|
tmp.seek(0)
|
||||||
@ -450,6 +463,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("D", 164.0 / 7) # groupes
|
||||||
ws.set_column_dimension_width("E", 115.0 / 7) # notes
|
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("F", 355.0 / 7) # remarques
|
||||||
|
ws.set_column_dimension_width("G", 72.0 / 7) # colonne NIP
|
||||||
|
ws.set_column_dimension_hidden("G", True) # colonne NIP cachée
|
||||||
|
|
||||||
# fontes
|
# fontes
|
||||||
font_base = Font(name="Arial", size=12)
|
font_base = Font(name="Arial", size=12)
|
||||||
@ -498,6 +513,13 @@ def excel_feuille_saisie(evaluation: "Evaluation", titreannee, description, line
|
|||||||
"border": border_top,
|
"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
|
# ligne de titres
|
||||||
ws.append_single_cell_row(
|
ws.append_single_cell_row(
|
||||||
"Feuille saisie note (à enregistrer au format excel)", style_titres
|
"Feuille saisie note (à enregistrer au format excel)", style_titres
|
||||||
@ -526,6 +548,7 @@ def excel_feuille_saisie(evaluation: "Evaluation", titreannee, description, line
|
|||||||
ws.make_cell("Groupe", style_titres),
|
ws.make_cell("Groupe", style_titres),
|
||||||
ws.make_cell("Note sur %g" % (evaluation.note_max or 0.0), 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("Remarque", style_titres),
|
||||||
|
ws.make_cell("NIP", style_titres),
|
||||||
]
|
]
|
||||||
)
|
)
|
||||||
|
|
||||||
@ -552,9 +575,13 @@ def excel_feuille_saisie(evaluation: "Evaluation", titreannee, description, line
|
|||||||
ws.make_cell(s, st),
|
ws.make_cell(s, st),
|
||||||
ws.make_cell(val, style_notes), # note
|
ws.make_cell(val, style_notes), # note
|
||||||
ws.make_cell(line[6], style_comment), # comment
|
ws.make_cell(line[6], style_comment), # comment
|
||||||
|
ws.make_cell(line[7], style_ro), # NIP
|
||||||
]
|
]
|
||||||
)
|
)
|
||||||
|
|
||||||
|
# ligne blanche
|
||||||
|
ws.append_blank_row()
|
||||||
|
|
||||||
# explication en bas
|
# explication en bas
|
||||||
ws.append_row([None, ws.make_cell("Code notes", style_titres)])
|
ws.append_row([None, ws.make_cell("Code notes", style_titres)])
|
||||||
ws.append_row(
|
ws.append_row(
|
||||||
|
@ -922,13 +922,11 @@ def feuille_saisie_notes(evaluation_id, group_ids=[]):
|
|||||||
|
|
||||||
# une liste de liste de chaines: lignes de la feuille de calcul
|
# une liste de liste de chaines: lignes de la feuille de calcul
|
||||||
rows = []
|
rows = []
|
||||||
|
|
||||||
etuds = _get_sorted_etuds(evaluation, etudids, formsemestre.id)
|
etuds = _get_sorted_etuds(evaluation, etudids, formsemestre.id)
|
||||||
for e in etuds:
|
for e in etuds:
|
||||||
etudid = e["etudid"]
|
etudid = e["etudid"]
|
||||||
groups = sco_groups.get_etud_groups(etudid, formsemestre.id)
|
groups = sco_groups.get_etud_groups(etudid, formsemestre.id)
|
||||||
grc = sco_groups.listgroups_abbrev(groups)
|
grc = sco_groups.listgroups_abbrev(groups)
|
||||||
|
|
||||||
rows.append(
|
rows.append(
|
||||||
[
|
[
|
||||||
str(etudid),
|
str(etudid),
|
||||||
@ -938,6 +936,7 @@ def feuille_saisie_notes(evaluation_id, group_ids=[]):
|
|||||||
grc,
|
grc,
|
||||||
e["val"],
|
e["val"],
|
||||||
e["explanation"],
|
e["explanation"],
|
||||||
|
e["code_nip"],
|
||||||
]
|
]
|
||||||
)
|
)
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user