forked from ScoDoc/ScoDoc
Table etud courants + export xlsx, + code nip
This commit is contained in:
parent
568c8681ba
commit
dcea12f6fc
@ -6,8 +6,10 @@
|
||||
|
||||
"""Liste simple d'étudiants
|
||||
"""
|
||||
import datetime
|
||||
|
||||
from app.models import FormSemestre, FormSemestreInscription, Identite
|
||||
from app.scodoc.sco_exceptions import ScoValueError
|
||||
from app.tables import table_builder as tb
|
||||
|
||||
|
||||
@ -79,7 +81,6 @@ class RowEtud(tb.Row):
|
||||
# formsemestre_id=res.formsemestre.id,
|
||||
# etudid=etud.id,
|
||||
# )
|
||||
url_bulletin = None # pour extension future
|
||||
self.add_cell("civilite_str", "Civ.", etud.civilite_str, "identite_detail")
|
||||
self.add_cell(
|
||||
"nom_disp",
|
||||
@ -91,19 +92,6 @@ class RowEtud(tb.Row):
|
||||
target_attrs={"class": "etudinfo discretelink", "id": str(etud.id)},
|
||||
)
|
||||
self.add_cell("prenom", "Prénom", etud.prenom, "identite_detail")
|
||||
# self.add_cell(
|
||||
# "nom_short",
|
||||
# "Nom",
|
||||
# etud.nom_short,
|
||||
# "identite_court",
|
||||
# data={
|
||||
# "order": etud.sort_key,
|
||||
# "etudid": etud.id,
|
||||
# "nomprenom": etud.nomprenom,
|
||||
# },
|
||||
# target=url_bulletin,
|
||||
# target_attrs={"class": "etudinfo", "id": str(etud.id)},
|
||||
# )
|
||||
|
||||
|
||||
def etuds_sorted_from_ids(etudids) -> list[Identite]:
|
||||
@ -149,6 +137,7 @@ class RowEtudWithInfos(RowEtud):
|
||||
""",
|
||||
"identite_detail",
|
||||
)
|
||||
self.add_cell("code_nip", "NIP", self.etud.code_nip or "", "identite_detail")
|
||||
super().add_etud_cols()
|
||||
self.add_cell(
|
||||
"etat",
|
||||
@ -180,6 +169,8 @@ class TableEtudWithInfos(TableEtud):
|
||||
|
||||
def table_etudiants_courants(formsemestres: list[FormSemestre]) -> TableEtud:
|
||||
"""Table des étudiants des formsemestres indiqués"""
|
||||
if not formsemestres:
|
||||
raise ScoValueError("Aucun semestre en cours")
|
||||
table = TableEtudWithInfos(row_class=RowEtudWithInfos)
|
||||
for formsemestre in formsemestres:
|
||||
table.add_formsemestre(formsemestre)
|
||||
|
20
app/templates/scolar/export_etudiants_courants.j2
Normal file
20
app/templates/scolar/export_etudiants_courants.j2
Normal file
@ -0,0 +1,20 @@
|
||||
{% extends "sco_page.j2" %}
|
||||
|
||||
{% block styles %}
|
||||
{{super()}}
|
||||
{% endblock %}
|
||||
|
||||
{% block app_content %}
|
||||
|
||||
<div class="tab-content">
|
||||
<h2>Étudiants des semestres courants</h2>
|
||||
|
||||
<a href="{{
|
||||
url_for('scolar.export_etudiants_courants', scodoc_dept=g.scodoc_dept, fmt='xls')
|
||||
}}">{{scu.ICON_XLS|safe}}</a>
|
||||
|
||||
|
||||
{{ table.html() | safe }}
|
||||
|
||||
</div>
|
||||
{% endblock %}
|
@ -2077,14 +2077,26 @@ def check_group_apogee(group_id, etat=None, fix=False, fixmail=False):
|
||||
@permission_required(Permission.ScoView)
|
||||
def export_etudiants_courants():
|
||||
"""Table export de tous les étudiants des formsemestres en cours."""
|
||||
fmt = request.args.get("fmt", "html")
|
||||
departement = Departement.query.get(g.scodoc_dept_id)
|
||||
if not departement:
|
||||
raise ScoValueError("département invalide")
|
||||
formsemestres = FormSemestre.get_dept_formsemestres_courants(departement)
|
||||
table = list_etuds.table_etudiants_courants(formsemestres)
|
||||
return render_template(
|
||||
"scolar/export_etudiants_courants.j2", sco=ScoData(), table=table
|
||||
)
|
||||
if fmt.startswith("xls"):
|
||||
return scu.send_file(
|
||||
table.excel(),
|
||||
f"""{formsemestres[0].departement.acronym}-etudiants-{
|
||||
datetime.datetime.now().strftime("%Y-%m-%dT%Hh%M")}""",
|
||||
scu.XLSX_SUFFIX,
|
||||
mime=scu.XLSX_MIMETYPE,
|
||||
)
|
||||
elif fmt == "html":
|
||||
return render_template(
|
||||
"scolar/export_etudiants_courants.j2", sco=ScoData(), table=table
|
||||
)
|
||||
else:
|
||||
raise ScoValueError("invalid fmt value")
|
||||
|
||||
|
||||
@bp.route("/form_students_import_excel", methods=["GET", "POST"])
|
||||
|
@ -1,7 +1,7 @@
|
||||
# -*- mode: python -*-
|
||||
# -*- coding: utf-8 -*-
|
||||
|
||||
SCOVERSION = "9.6.62"
|
||||
SCOVERSION = "9.6.63"
|
||||
|
||||
SCONAME = "ScoDoc"
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user