1
0
forked from ScoDoc/ScoDoc

Exports excel recap et jury

This commit is contained in:
Emmanuel Viennet 2023-03-12 12:30:57 +01:00
parent 44d832bbd5
commit 1cc11cc932
3 changed files with 19 additions and 20 deletions

View File

@ -95,11 +95,14 @@ def formsemestre_recapcomplet(
xml_with_decisions = int(xml_with_decisions)
force_publishing = int(force_publishing)
filename = scu.sanitize_filename(
f"""recap-{formsemestre.titre_num()}-{time.strftime("%Y-%m-%d")}"""
f"""{'jury' if mode_jury else 'recap'
}{'-evals' if tabformat == 'xlsall' else ''
}-{formsemestre.titre_num()}-{time.strftime("%Y-%m-%d")}"""
)
if is_file:
return _formsemestre_recapcomplet_to_file(
formsemestre,
mode_jury=mode_jury,
tabformat=tabformat,
filename=filename,
xml_with_decisions=xml_with_decisions,
@ -275,6 +278,7 @@ def _formsemestre_recapcomplet_to_html(
def _formsemestre_recapcomplet_to_file(
formsemestre: FormSemestre,
tabformat: str = "json", # xml, xls, xlsall, json
mode_jury: bool = False,
filename: str = "",
xml_nodate=False, # format XML sans dates (sert pour debug cache: comparaison de XML)
xml_with_decisions=False,
@ -282,19 +286,15 @@ def _formsemestre_recapcomplet_to_file(
):
"""Calcule et renvoie le tableau récapitulatif."""
if tabformat.startswith("xls"):
include_evaluations = tabformat == "xlsall"
res: NotesTableCompat = res_sem.load_formsemestre_results(formsemestre)
include_evaluations = tabformat in {
"xlsall",
"csv ",
} # csv not supported anymore
if tabformat != "csv":
tabformat = "xlsx"
data, filename = gen_formsemestre_recapcomplet_excel(
res,
mode_jury=mode_jury,
include_evaluations=include_evaluations,
filename=filename,
)
mime, suffix = scu.get_mime_suffix(tabformat)
mime, suffix = scu.get_mime_suffix("xlsx")
return scu.send_file(data, filename=filename, mime=mime, suffix=suffix)
elif tabformat == "xml":
data = gen_formsemestre_recapcomplet_xml(
@ -458,7 +458,6 @@ def gen_formsemestre_recapcomplet_html_table(
table_html = cache_class.get(formsemestre.id)
if table_html is None:
table = _gen_formsemestre_recapcomplet_table(
formsemestre,
res,
include_evaluations,
mode_jury,
@ -472,10 +471,10 @@ def gen_formsemestre_recapcomplet_html_table(
def _gen_formsemestre_recapcomplet_table(
formsemestre: FormSemestre,
res: ResultatsSemestre,
include_evaluations=False,
mode_jury=False,
convert_values: bool = True,
filename: str = "",
selected_etudid=None,
) -> TableRecap:
@ -483,10 +482,10 @@ def _gen_formsemestre_recapcomplet_table(
table_class = TableJury if mode_jury else TableRecap
table = table_class(
res,
convert_values=True,
convert_values=convert_values,
include_evaluations=include_evaluations,
mode_jury=mode_jury,
read_only=not formsemestre.can_edit_jury(),
read_only=not res.formsemestre.can_edit_jury(),
)
table.data["filename"] = filename
@ -496,21 +495,21 @@ def _gen_formsemestre_recapcomplet_table(
def gen_formsemestre_recapcomplet_excel(
res: NotesTableCompat,
mode_jury: bool = False,
include_evaluations=False,
filename: str = "",
) -> tuple:
"""Génère le tableau recap en excel (xlsx).
Utilisé pour archives et autres besoins particuliers (API).
"""Génère le tableau recap ou jury en excel (xlsx).
Utilisé pour menu (export excel), archives et autres besoins particuliers (API).
Attention: le tableau exporté depuis la page html est celui généré en js par DataTables,
et non celui-ci.
"""
filename += scu.XLSX_SUFFIX
table = TableRecap(
table = _gen_formsemestre_recapcomplet_table(
res,
convert_values=False,
include_evaluations=include_evaluations,
# preferences=sco_preferences.SemPreferences(formsemestre_id=formsemestre.id),
mode_jury=mode_jury,
convert_values=False,
filename=filename,
)
return table.excel(), filename

View File

@ -369,7 +369,7 @@ div.logo-logo img {
box-sizing: content-box;
margin-top: 10px;
/* -10px */
width: 130px;
width: 64px;
/* adapter suivant image */
/* padding-right: 5px; */
}

Binary file not shown.

Before

Width:  |  Height:  |  Size: 69 KiB

After

Width:  |  Height:  |  Size: 19 KiB