1
0
forked from ScoDoc/ScoDoc

modification feuille appel closes #876

This commit is contained in:
Iziram 2024-07-12 10:22:03 +02:00
parent 62e4481c77
commit 75665497fa

View File

@ -639,8 +639,23 @@ def excel_feuille_listeappel(
with_codes=False, with_codes=False,
with_paiement=False, with_paiement=False,
server_name=None, server_name=None,
edt_params: dict = None,
): ):
"""generation feuille appel""" """generation feuille appel
edt_params :
- "discipline" : Discipline
- "ens" : Enseignant
- "date" : Date (format JJ/MM/AAAA)
- "heure" : Heure (format HH:MM)
"""
# Obligatoire sinon import circulaire
# pylint: disable=import-outside-toplevel
from app.scodoc.sco_groups import listgroups_abbrev, get_etud_groups
if edt_params is None:
edt_params = {}
if partitions is None: if partitions is None:
partitions = [] partitions = []
formsemestre_id = sem["formsemestre_id"] formsemestre_id = sem["formsemestre_id"]
@ -648,8 +663,8 @@ def excel_feuille_listeappel(
ws = ScoExcelSheet(sheet_name) ws = ScoExcelSheet(sheet_name)
ws.set_column_dimension_width("A", 3) ws.set_column_dimension_width("A", 3)
ws.set_column_dimension_width("B", 35) max_name_width: int = 35
ws.set_column_dimension_width("C", 12) letter_int: int = ord("B")
font1 = Font(name="Arial", size=11) font1 = Font(name="Arial", size=11)
font1i = Font(name="Arial", size=10, italic=True) font1i = Font(name="Arial", size=10, italic=True)
@ -675,11 +690,6 @@ def excel_feuille_listeappel(
"font": Font(name="Arial", size=14), "font": Font(name="Arial", size=14),
} }
style2b = {
"font": font1i,
"border": border_tblr,
}
style2t3 = { style2t3 = {
"border": border_tblr, "border": border_tblr,
} }
@ -693,8 +703,6 @@ def excel_feuille_listeappel(
"font": Font(name="Arial", bold=True, size=14), "font": Font(name="Arial", bold=True, size=14),
} }
nb_weeks = 4 # nombre de colonnes pour remplir absences
# ligne 1 # ligne 1
title = "%s %s (%s - %s)" % ( title = "%s %s (%s - %s)" % (
sco_preferences.get_preference("DeptName", formsemestre_id), sco_preferences.get_preference("DeptName", formsemestre_id),
@ -706,35 +714,67 @@ def excel_feuille_listeappel(
ws.append_row([None, ws.make_cell(title, style2)]) ws.append_row([None, ws.make_cell(title, style2)])
# ligne 2 # ligne 2
ws.append_row([None, ws.make_cell("Discipline :", style2)]) ws.append_row(
[
None,
ws.make_cell("Discipline :", style2),
ws.make_cell(edt_params.get("discipline", ""), style3),
]
)
# ligne 3 # ligne 3
cell_2 = ws.make_cell("Enseignant :", style2) cell_2 = ws.make_cell("Enseignant :", style2)
cell_6 = ws.make_cell(f"Groupe {groupname}", style3) cell_6 = ws.make_cell(f"Groupe {groupname}", style3)
ws.append_row([None, cell_2, None, None, None, None, cell_6]) ws.append_row(
[None, cell_2, ws.make_cell(edt_params.get("ens", ""), style3), cell_6]
)
# ligne 4: Avertissement pour ne pas confondre avec listes notes # ligne 4: Avertissement pour ne pas confondre avec listes notes + Date
cell_1 = ws.make_cell("Date :", style2)
cell_2 = ws.make_cell( cell_2 = ws.make_cell(
"Ne pas utiliser cette feuille pour saisir les notes !", style1i "Ne pas utiliser cette feuille pour saisir les notes !", style1i
) )
ws.append_row([None, None, cell_2]) ws.append_row([None, cell_1, ws.make_cell(edt_params.get("date", ""))])
# ligne 5 : Heure
ws.append_row(
[
None,
ws.make_cell("Heure :", style2),
ws.make_cell(edt_params.get("heure", "")),
]
)
ws.append_blank_row() ws.append_blank_row()
ws.append_blank_row() ws.append_row([None, cell_2])
# ligne 7: Entête (contruction dans une liste cells) # ligne 8: Entête (contruction dans une liste cells)
cell_2 = ws.make_cell("Nom", style3) cell_2 = ws.make_cell("Nom", style3)
cells = [None, cell_2] cells = [None, cell_2]
letter_int += 1
p_name: list = []
for partition in partitions: for partition in partitions:
cells.append(ws.make_cell(partition["partition_name"], style3)) p_name.append(partition["partition_name"])
p_name: str = " / ".join(p_name)
ws.set_column_dimension_width(chr(letter_int), len(p_name))
if with_codes: if with_codes:
cells.append(ws.make_cell("etudid", style3)) cells.append(ws.make_cell("etudid", style3))
cells.append(ws.make_cell("code_nip", style3)) cells.append(ws.make_cell("code_nip", style3))
cells.append(ws.make_cell("code_ine", style3)) cells.append(ws.make_cell("code_ine", style3))
for i in range(nb_weeks):
cells.append(ws.make_cell("", style2b)) # case Groupes
cells.append(ws.make_cell("Groupes", style3))
letter_int += 1
ws.set_column_dimension_width(chr(letter_int), 30)
# case émargement
cells.append(ws.make_cell("Émargement", style3))
letter_int += 1
ws.set_column_dimension_width(chr(letter_int), 30)
ws.append_row(cells) ws.append_row(cells)
row_id: int = len(ws.rows) + 1
n = 0 n = 0
# pour chaque étudiant # pour chaque étudiant
for t in lines: for t in lines:
@ -742,6 +782,8 @@ def excel_feuille_listeappel(
nomprenom = ( nomprenom = (
t["civilite_str"] + " " + t["nom"] + " " + t["prenom"].lower().capitalize() t["civilite_str"] + " " + t["nom"] + " " + t["prenom"].lower().capitalize()
) )
name_width = min(max_name_width, (len(nomprenom) + 2.0) * 1.25)
ws.set_column_dimension_width("B", name_width)
style_nom = style2t3 style_nom = style2t3
if with_paiement: if with_paiement:
paie = t.get("paiementinscription", None) paie = t.get("paiementinscription", None)
@ -754,22 +796,19 @@ def excel_feuille_listeappel(
cell_1 = ws.make_cell(n, style1b) cell_1 = ws.make_cell(n, style1b)
cell_2 = ws.make_cell(nomprenom, style_nom) cell_2 = ws.make_cell(nomprenom, style_nom)
cells = [cell_1, cell_2] cells = [cell_1, cell_2]
group = get_etud_groups(t["etudid"], formsemestre_id=formsemestre_id)
for partition in partitions: cells.append(ws.make_cell(listgroups_abbrev(group), style2t3))
if partition["partition_name"]:
cells.append(
ws.make_cell(t.get(partition["partition_id"], ""), style2t3)
)
if with_codes: if with_codes:
cells.append(ws.make_cell(t["etudid"], style2t3)) cells.append(ws.make_cell(t["etudid"], style2t3))
code_nip = t.get("code_nip", "") code_nip = t.get("code_nip", "")
cells.append(ws.make_cell(code_nip, style2t3)) cells.append(ws.make_cell(code_nip, style2t3))
code_ine = t.get("code_ine", "") code_ine = t.get("code_ine", "")
cells.append(ws.make_cell(code_ine, style2t3)) cells.append(ws.make_cell(code_ine, style2t3))
cells.append(ws.make_cell(t.get("etath", ""), style2b))
for i in range(1, nb_weeks): cells.append(ws.make_cell(style=style2t3))
cells.append(ws.make_cell(style=style2t3))
ws.append_row(cells) ws.append_row(cells)
ws.set_row_dimension_height(row_id, 30)
row_id += 1
ws.append_blank_row() ws.append_blank_row()