2020-09-26 16:19:37 +02:00
|
|
|
# -*- mode: python -*-
|
|
|
|
# -*- coding: utf-8 -*-
|
|
|
|
|
|
|
|
##############################################################################
|
|
|
|
#
|
|
|
|
# Gestion scolarite IUT
|
|
|
|
#
|
2023-12-31 23:04:06 +01:00
|
|
|
# Copyright (c) 1999 - 2024 Emmanuel Viennet. All rights reserved.
|
2020-09-26 16:19:37 +02:00
|
|
|
#
|
|
|
|
# This program is free software; you can redistribute it and/or modify
|
|
|
|
# it under the terms of the GNU General Public License as published by
|
|
|
|
# the Free Software Foundation; either version 2 of the License, or
|
|
|
|
# (at your option) any later version.
|
|
|
|
#
|
|
|
|
# This program is distributed in the hope that it will be useful,
|
|
|
|
# but WITHOUT ANY WARRANTY; without even the implied warranty of
|
|
|
|
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
|
|
|
# GNU General Public License for more details.
|
|
|
|
#
|
|
|
|
# You should have received a copy of the GNU General Public License
|
|
|
|
# along with this program; if not, write to the Free Software
|
|
|
|
# Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
|
|
|
|
#
|
|
|
|
# Emmanuel Viennet emmanuel.viennet@viennet.net
|
|
|
|
#
|
|
|
|
##############################################################################
|
|
|
|
|
|
|
|
"""Form. pour inscription rapide des etudiants d'un semestre dans un autre
|
|
|
|
Utilise les autorisations d'inscription délivrées en jury.
|
|
|
|
"""
|
2021-02-04 20:02:44 +01:00
|
|
|
import datetime
|
2021-07-09 23:19:30 +02:00
|
|
|
from operator import itemgetter
|
2020-09-26 16:19:37 +02:00
|
|
|
|
2024-08-23 23:16:49 +02:00
|
|
|
from flask import url_for, g, render_template, request
|
2021-07-11 17:37:12 +02:00
|
|
|
|
2021-06-19 23:21:37 +02:00
|
|
|
import app.scodoc.notesdb as ndb
|
|
|
|
import app.scodoc.sco_utils as scu
|
2023-07-11 06:57:38 +02:00
|
|
|
from app import db, log
|
2024-02-19 19:10:12 +01:00
|
|
|
from app.models import Formation, FormSemestre, GroupDescr, Identite
|
2021-06-19 23:21:37 +02:00
|
|
|
from app.scodoc.gen_tables import GenTable
|
2023-01-26 18:29:16 +01:00
|
|
|
from app.scodoc import sco_cache
|
2023-02-12 13:36:47 +01:00
|
|
|
from app.scodoc import codes_cursus
|
2023-01-26 18:29:16 +01:00
|
|
|
from app.scodoc import sco_etud
|
2021-06-19 23:21:37 +02:00
|
|
|
from app.scodoc import sco_formsemestre_inscriptions
|
|
|
|
from app.scodoc import sco_groups
|
2023-01-26 18:29:16 +01:00
|
|
|
from app.scodoc import sco_preferences
|
2023-02-19 15:45:27 +01:00
|
|
|
from app.scodoc import sco_pv_dict
|
2021-06-19 23:21:37 +02:00
|
|
|
from app.scodoc.sco_exceptions import ScoValueError
|
2020-09-26 16:19:37 +02:00
|
|
|
|
|
|
|
|
2024-02-19 19:10:12 +01:00
|
|
|
def _list_authorized_etuds_by_sem(
|
|
|
|
formsemestre: FormSemestre, ignore_jury=False
|
|
|
|
) -> tuple[dict[int, dict], list[dict], dict[int, Identite]]:
|
2020-09-26 16:19:37 +02:00
|
|
|
"""Liste des etudiants autorisés à s'inscrire dans sem.
|
|
|
|
delai = nb de jours max entre la date de l'autorisation et celle de debut du semestre cible.
|
2023-01-26 18:29:16 +01:00
|
|
|
ignore_jury: si vrai, considère tous les étudiants comme autorisés, même
|
2022-01-18 22:01:30 +01:00
|
|
|
s'ils n'ont pas de décision de jury.
|
2020-09-26 16:19:37 +02:00
|
|
|
"""
|
2024-02-19 19:10:12 +01:00
|
|
|
src_sems = _list_source_sems(formsemestre)
|
|
|
|
inscrits = list_inscrits(formsemestre.id)
|
2020-09-26 16:19:37 +02:00
|
|
|
r = {}
|
|
|
|
candidats = {} # etudid : etud (tous les etudiants candidats)
|
|
|
|
nb = 0 # debug
|
2024-02-19 19:10:12 +01:00
|
|
|
src_formsemestre: FormSemestre
|
|
|
|
for src_formsemestre in src_sems:
|
2022-01-18 22:01:30 +01:00
|
|
|
if ignore_jury:
|
|
|
|
# liste de tous les inscrits au semestre (sans dems)
|
2024-02-22 13:34:03 +01:00
|
|
|
etud_list = list_inscrits(src_formsemestre.id).values()
|
2022-01-18 22:01:30 +01:00
|
|
|
else:
|
|
|
|
# liste des étudiants autorisés par le jury à s'inscrire ici
|
2024-02-19 19:10:12 +01:00
|
|
|
etud_list = _list_etuds_from_sem(src_formsemestre, formsemestre)
|
2020-09-26 16:19:37 +02:00
|
|
|
liste_filtree = []
|
2024-02-19 19:10:12 +01:00
|
|
|
for e in etud_list:
|
2020-09-26 16:19:37 +02:00
|
|
|
# Filtre ceux qui se sont déjà inscrit dans un semestre APRES le semestre src
|
|
|
|
auth_used = False # autorisation deja utilisée ?
|
2024-02-19 19:10:12 +01:00
|
|
|
etud = Identite.get_etud(e["etudid"])
|
|
|
|
for inscription in etud.inscriptions():
|
|
|
|
if inscription.formsemestre.date_debut >= src_formsemestre.date_fin:
|
2020-09-26 16:19:37 +02:00
|
|
|
auth_used = True
|
|
|
|
if not auth_used:
|
|
|
|
candidats[e["etudid"]] = etud
|
|
|
|
liste_filtree.append(e)
|
|
|
|
nb += 1
|
2024-02-19 19:10:12 +01:00
|
|
|
r[src_formsemestre.id] = {
|
2020-09-26 16:19:37 +02:00
|
|
|
"etuds": liste_filtree,
|
|
|
|
"infos": {
|
2024-02-19 19:10:12 +01:00
|
|
|
"id": src_formsemestre.id,
|
|
|
|
"title": src_formsemestre.titre_annee(),
|
|
|
|
"title_target": url_for(
|
|
|
|
"notes.formsemestre_status",
|
|
|
|
scodoc_dept=g.scodoc_dept,
|
|
|
|
formsemestre_id=src_formsemestre.id,
|
|
|
|
),
|
2021-09-25 10:43:06 +02:00
|
|
|
"filename": "etud_autorises",
|
2020-09-26 16:19:37 +02:00
|
|
|
},
|
|
|
|
}
|
|
|
|
# ajoute attribut inscrit qui indique si l'étudiant est déjà inscrit dans le semestre dest.
|
2024-02-19 19:10:12 +01:00
|
|
|
for e in r[src_formsemestre.id]["etuds"]:
|
2021-07-09 17:47:06 +02:00
|
|
|
e["inscrit"] = e["etudid"] in inscrits
|
2020-09-26 16:19:37 +02:00
|
|
|
|
|
|
|
# Ajoute liste des etudiants actuellement inscrits
|
|
|
|
for e in inscrits.values():
|
|
|
|
e["inscrit"] = True
|
2024-02-19 19:10:12 +01:00
|
|
|
r[formsemestre.id] = {
|
2021-07-09 17:47:06 +02:00
|
|
|
"etuds": list(inscrits.values()),
|
2020-09-26 16:19:37 +02:00
|
|
|
"infos": {
|
2024-02-19 19:10:12 +01:00
|
|
|
"id": formsemestre.id,
|
|
|
|
"title": "Semestre cible: " + formsemestre.titre_annee(),
|
|
|
|
"title_target": url_for(
|
|
|
|
"notes.formsemestre_status",
|
|
|
|
scodoc_dept=g.scodoc_dept,
|
|
|
|
formsemestre_id=formsemestre.id,
|
|
|
|
),
|
2020-09-26 16:19:37 +02:00
|
|
|
"comment": " actuellement inscrits dans ce semestre",
|
|
|
|
"help": "Ces étudiants sont actuellement inscrits dans ce semestre. Si vous les décochez, il seront désinscrits.",
|
2021-09-25 10:43:06 +02:00
|
|
|
"filename": "etud_inscrits",
|
2020-09-26 16:19:37 +02:00
|
|
|
},
|
|
|
|
}
|
|
|
|
|
|
|
|
return r, inscrits, candidats
|
|
|
|
|
|
|
|
|
2024-02-19 19:10:12 +01:00
|
|
|
def list_inscrits(formsemestre_id: int, with_dems=False) -> list[dict]:
|
2022-09-03 11:41:56 +02:00
|
|
|
"""Étudiants déjà inscrits à ce semestre
|
2020-09-26 16:19:37 +02:00
|
|
|
{ etudid : etud }
|
|
|
|
"""
|
|
|
|
if not with_dems:
|
2021-06-21 10:17:16 +02:00
|
|
|
ins = sco_formsemestre_inscriptions.do_formsemestre_inscription_listinscrits(
|
2021-08-19 10:28:35 +02:00
|
|
|
formsemestre_id
|
2020-09-26 16:19:37 +02:00
|
|
|
) # optimized
|
|
|
|
else:
|
|
|
|
args = {"formsemestre_id": formsemestre_id}
|
2021-08-19 10:28:35 +02:00
|
|
|
ins = sco_formsemestre_inscriptions.do_formsemestre_inscription_list(args=args)
|
2020-09-26 16:19:37 +02:00
|
|
|
inscr = {}
|
|
|
|
for i in ins:
|
|
|
|
etudid = i["etudid"]
|
2021-06-19 23:21:37 +02:00
|
|
|
inscr[etudid] = sco_etud.get_etud_info(etudid=etudid, filled=True)[0]
|
2020-09-26 16:19:37 +02:00
|
|
|
return inscr
|
|
|
|
|
|
|
|
|
2024-02-19 19:10:12 +01:00
|
|
|
def _list_etuds_from_sem(src: FormSemestre, dst: FormSemestre) -> list[dict]:
|
|
|
|
"""Liste des étudiants du semestre src qui sont autorisés à passer dans le semestre dst."""
|
|
|
|
target_semestre_id = dst.semestre_id
|
|
|
|
dpv = sco_pv_dict.dict_pvjury(src.id)
|
2020-09-26 16:19:37 +02:00
|
|
|
if not dpv:
|
|
|
|
return []
|
|
|
|
etuds = [
|
|
|
|
x["identite"]
|
|
|
|
for x in dpv["decisions"]
|
2024-02-19 19:10:12 +01:00
|
|
|
if target_semestre_id in [a["semestre_id"] for a in x["autorisations"]]
|
2020-09-26 16:19:37 +02:00
|
|
|
]
|
|
|
|
return etuds
|
|
|
|
|
|
|
|
|
2024-02-19 19:10:12 +01:00
|
|
|
def list_inscrits_date(formsemestre: FormSemestre):
|
|
|
|
"""Liste les etudiants inscrits à la date de début de formsemestre
|
|
|
|
dans n'importe quel semestre du même département
|
|
|
|
SAUF formsemestre
|
2020-09-26 16:19:37 +02:00
|
|
|
"""
|
2021-06-15 13:59:56 +02:00
|
|
|
cnx = ndb.GetDBConnexion()
|
2021-02-03 22:00:41 +01:00
|
|
|
cursor = cnx.cursor(cursor_factory=ndb.ScoDocCursor)
|
2020-09-26 16:19:37 +02:00
|
|
|
cursor.execute(
|
2021-09-15 00:54:18 +02:00
|
|
|
"""SELECT ins.etudid
|
|
|
|
FROM
|
|
|
|
notes_formsemestre_inscription ins,
|
2021-09-15 15:19:08 +02:00
|
|
|
notes_formsemestre S
|
2021-09-13 22:10:01 +02:00
|
|
|
WHERE ins.formsemestre_id = S.id
|
2021-08-21 15:17:14 +02:00
|
|
|
AND S.id != %(formsemestre_id)s
|
|
|
|
AND S.date_debut <= %(date_debut_iso)s
|
|
|
|
AND S.date_fin >= %(date_debut_iso)s
|
2021-09-15 00:54:18 +02:00
|
|
|
AND S.dept_id = %(dept_id)s
|
2021-08-21 15:17:14 +02:00
|
|
|
""",
|
2024-02-19 19:10:12 +01:00
|
|
|
{
|
|
|
|
"formsemestre_id": formsemestre.id,
|
|
|
|
"date_debut_iso": formsemestre.date_debut.isoformat(),
|
|
|
|
"dept_id": formsemestre.dept_id,
|
|
|
|
},
|
2020-09-26 16:19:37 +02:00
|
|
|
)
|
|
|
|
return [x[0] for x in cursor.fetchall()]
|
|
|
|
|
|
|
|
|
2024-02-19 19:10:12 +01:00
|
|
|
def do_inscrit(
|
|
|
|
formsemestre: FormSemestre, etudids, inscrit_groupes=False, inscrit_parcours=False
|
|
|
|
):
|
2020-09-26 16:19:37 +02:00
|
|
|
"""Inscrit ces etudiants dans ce semestre
|
|
|
|
(la liste doit avoir été vérifiée au préalable)
|
2023-08-31 13:38:17 +02:00
|
|
|
En option:
|
|
|
|
- Si inscrit_groupes, inscrit aux mêmes groupes que dans le semestre origine
|
|
|
|
(toutes partitions, y compris parcours)
|
|
|
|
- Si inscrit_parcours, inscrit au même groupe de parcours (mais ignore les autres partitions)
|
|
|
|
(si les deux sont vrais, inscrit_parcours n'a pas d'effet)
|
2020-09-26 16:19:37 +02:00
|
|
|
"""
|
2023-08-31 13:38:17 +02:00
|
|
|
# TODO à ré-écrire pour utiliser les modèles, notamment GroupDescr
|
2023-01-24 00:35:15 +01:00
|
|
|
formsemestre.setup_parcours_groups()
|
2022-09-30 22:43:39 +02:00
|
|
|
log(f"do_inscrit (inscrit_groupes={inscrit_groupes}): {etudids}")
|
2020-09-26 16:19:37 +02:00
|
|
|
for etudid in etudids:
|
|
|
|
sco_formsemestre_inscriptions.do_formsemestre_inscription_with_modules(
|
2024-02-19 19:10:12 +01:00
|
|
|
formsemestre.id,
|
2020-09-26 16:19:37 +02:00
|
|
|
etudid,
|
2022-09-30 22:43:39 +02:00
|
|
|
etat=scu.INSCRIT,
|
2020-09-26 16:19:37 +02:00
|
|
|
method="formsemestre_inscr_passage",
|
|
|
|
)
|
2023-08-31 13:38:17 +02:00
|
|
|
if inscrit_groupes or inscrit_parcours:
|
2020-09-26 16:19:37 +02:00
|
|
|
# Inscription dans les mêmes groupes que ceux du semestre d'origine,
|
|
|
|
# s'ils existent.
|
|
|
|
# (mise en correspondance à partir du nom du groupe, sans tenir compte
|
|
|
|
# du nom de la partition: évidemment, cela ne marche pas si on a les
|
|
|
|
# même noms de groupes dans des partitions différentes)
|
2021-06-19 23:21:37 +02:00
|
|
|
etud = sco_etud.get_etud_info(etudid=etudid, filled=True)[0]
|
2020-09-26 16:19:37 +02:00
|
|
|
|
|
|
|
# recherche le semestre origine (il serait plus propre de l'avoir conservé!)
|
|
|
|
if len(etud["sems"]) < 2:
|
|
|
|
continue
|
|
|
|
prev_formsemestre = etud["sems"][1]
|
2022-03-05 12:47:08 +01:00
|
|
|
sco_groups.etud_add_group_infos(
|
|
|
|
etud,
|
|
|
|
prev_formsemestre["formsemestre_id"] if prev_formsemestre else None,
|
|
|
|
)
|
2020-09-26 16:19:37 +02:00
|
|
|
|
2023-01-24 00:35:15 +01:00
|
|
|
cursem_groups_by_name = {
|
|
|
|
g["group_name"]: g
|
2024-02-19 19:10:12 +01:00
|
|
|
for g in sco_groups.get_sem_groups(formsemestre.id)
|
2023-01-24 00:35:15 +01:00
|
|
|
if g["group_name"]
|
|
|
|
}
|
2020-09-26 16:19:37 +02:00
|
|
|
|
|
|
|
# forme la liste des groupes présents dans les deux semestres:
|
|
|
|
partition_groups = [] # [ partition+group ] (ds nouveau sem.)
|
|
|
|
for partition_id in etud["partitions"]:
|
|
|
|
prev_group_name = etud["partitions"][partition_id]["group_name"]
|
|
|
|
if prev_group_name in cursem_groups_by_name:
|
|
|
|
new_group = cursem_groups_by_name[prev_group_name]
|
|
|
|
partition_groups.append(new_group)
|
|
|
|
|
2023-01-24 00:35:15 +01:00
|
|
|
# Inscrit aux groupes
|
2020-09-26 16:19:37 +02:00
|
|
|
for partition_group in partition_groups:
|
2023-07-11 06:57:38 +02:00
|
|
|
group: GroupDescr = db.session.get(
|
|
|
|
GroupDescr, partition_group["group_id"]
|
|
|
|
)
|
2023-08-31 13:38:17 +02:00
|
|
|
if inscrit_groupes or (
|
|
|
|
group.partition.partition_name == scu.PARTITION_PARCOURS
|
|
|
|
and inscrit_parcours
|
|
|
|
):
|
|
|
|
sco_groups.change_etud_group_in_partition(etudid, group)
|
2020-09-26 16:19:37 +02:00
|
|
|
|
|
|
|
|
2024-02-19 19:10:12 +01:00
|
|
|
def do_desinscrit(
|
|
|
|
formsemestre: FormSemestre, etudids: list[int], check_has_dec_jury=True
|
|
|
|
):
|
2023-08-31 13:38:17 +02:00
|
|
|
"désinscrit les étudiants indiqués du formsemestre"
|
|
|
|
log(f"do_desinscrit: {etudids}")
|
2020-09-26 16:19:37 +02:00
|
|
|
for etudid in etudids:
|
2021-06-21 10:17:16 +02:00
|
|
|
sco_formsemestre_inscriptions.do_formsemestre_desinscription(
|
2024-02-19 19:10:12 +01:00
|
|
|
etudid, formsemestre.id, check_has_dec_jury=check_has_dec_jury
|
2020-09-26 16:19:37 +02:00
|
|
|
)
|
|
|
|
|
|
|
|
|
2024-02-19 19:10:12 +01:00
|
|
|
def _list_source_sems(formsemestre: FormSemestre) -> list[FormSemestre]:
|
2020-09-26 16:19:37 +02:00
|
|
|
"""Liste des semestres sources
|
2024-02-19 19:10:12 +01:00
|
|
|
formsemestre est le semestre destination
|
2020-09-26 16:19:37 +02:00
|
|
|
"""
|
2024-02-19 19:10:12 +01:00
|
|
|
# liste des semestres du même type de cursus terminant
|
|
|
|
# pas trop loin de la date de début du semestre destination
|
|
|
|
date_fin_min = formsemestre.date_debut - datetime.timedelta(days=275)
|
|
|
|
date_fin_max = formsemestre.date_debut + datetime.timedelta(days=45)
|
|
|
|
return (
|
|
|
|
FormSemestre.query.filter(
|
|
|
|
FormSemestre.dept_id == formsemestre.dept_id,
|
|
|
|
# saute le semestre destination:
|
|
|
|
FormSemestre.id != formsemestre.id,
|
|
|
|
# et les semestres de formations speciales (monosemestres):
|
|
|
|
FormSemestre.semestre_id != codes_cursus.NO_SEMESTRE_ID,
|
|
|
|
# semestre pas trop dans le futur
|
|
|
|
FormSemestre.date_fin <= date_fin_max,
|
|
|
|
# ni trop loin dans le passé
|
|
|
|
FormSemestre.date_fin >= date_fin_min,
|
|
|
|
)
|
|
|
|
.join(Formation)
|
|
|
|
.filter_by(type_parcours=formsemestre.formation.type_parcours)
|
|
|
|
).all()
|
2020-09-26 16:19:37 +02:00
|
|
|
|
|
|
|
|
2024-02-19 19:10:12 +01:00
|
|
|
# view, GET, POST
|
2020-09-26 16:19:37 +02:00
|
|
|
def formsemestre_inscr_passage(
|
|
|
|
formsemestre_id,
|
2024-02-19 19:10:12 +01:00
|
|
|
etuds: str | list[int] | list[str] | int | None = None,
|
2020-09-26 16:19:37 +02:00
|
|
|
inscrit_groupes=False,
|
2023-08-31 13:38:17 +02:00
|
|
|
inscrit_parcours=False,
|
2020-09-26 16:19:37 +02:00
|
|
|
submitted=False,
|
|
|
|
dialog_confirmed=False,
|
2022-01-18 22:01:30 +01:00
|
|
|
ignore_jury=False,
|
2023-01-26 18:29:16 +01:00
|
|
|
) -> str:
|
|
|
|
"""Page Form. pour inscription des etudiants d'un semestre dans un autre
|
2020-09-26 16:19:37 +02:00
|
|
|
(donné par formsemestre_id).
|
|
|
|
Permet de selectionner parmi les etudiants autorisés à s'inscrire.
|
|
|
|
Principe:
|
|
|
|
- trouver liste d'etud, par semestre
|
|
|
|
- afficher chaque semestre "boites" avec cases à cocher
|
|
|
|
- si l'étudiant est déjà inscrit, le signaler (gras, nom de groupes): il peut être désinscrit
|
|
|
|
- on peut choisir les groupes TD, TP, TA
|
2023-01-26 18:29:16 +01:00
|
|
|
- seuls les étudiants non inscrits changent (de groupe)
|
|
|
|
- les étudiants inscrit qui se trouvent décochés sont désinscrits
|
2020-12-02 01:00:23 +01:00
|
|
|
- Confirmation: indiquer les étudiants inscrits et ceux désinscrits, le total courant.
|
2020-09-26 16:19:37 +02:00
|
|
|
|
|
|
|
"""
|
2024-02-19 19:10:12 +01:00
|
|
|
formsemestre = FormSemestre.get_formsemestre(formsemestre_id)
|
2020-09-26 16:19:37 +02:00
|
|
|
inscrit_groupes = int(inscrit_groupes)
|
2023-08-31 13:38:17 +02:00
|
|
|
inscrit_parcours = int(inscrit_parcours)
|
2022-01-18 22:01:30 +01:00
|
|
|
ignore_jury = int(ignore_jury)
|
2020-09-26 16:19:37 +02:00
|
|
|
# -- check lock
|
2024-02-19 19:10:12 +01:00
|
|
|
if not formsemestre.etat:
|
2020-09-26 16:19:37 +02:00
|
|
|
raise ScoValueError("opération impossible: semestre verrouille")
|
2024-08-23 23:16:49 +02:00
|
|
|
H = []
|
2024-02-19 19:10:12 +01:00
|
|
|
etuds = [] if etuds is None else etuds
|
2021-09-27 13:43:11 +02:00
|
|
|
if isinstance(etuds, str):
|
2024-02-19 19:10:12 +01:00
|
|
|
# string, vient du form de confirmation
|
2021-11-27 18:55:47 +01:00
|
|
|
etuds = [int(x) for x in etuds.split(",") if x]
|
2021-09-27 13:43:11 +02:00
|
|
|
elif isinstance(etuds, int):
|
|
|
|
etuds = [etuds]
|
2022-01-07 18:38:32 +01:00
|
|
|
elif etuds and isinstance(etuds[0], str):
|
|
|
|
etuds = [int(x) for x in etuds]
|
2021-11-27 18:55:47 +01:00
|
|
|
|
2024-02-19 19:10:12 +01:00
|
|
|
auth_etuds_by_sem, inscrits, candidats = _list_authorized_etuds_by_sem(
|
|
|
|
formsemestre, ignore_jury=ignore_jury
|
2022-01-18 22:01:30 +01:00
|
|
|
)
|
2020-12-02 01:00:23 +01:00
|
|
|
etuds_set = set(etuds)
|
|
|
|
candidats_set = set(candidats)
|
|
|
|
inscrits_set = set(inscrits)
|
2020-09-26 16:19:37 +02:00
|
|
|
candidats_non_inscrits = candidats_set - inscrits_set
|
2024-02-19 19:10:12 +01:00
|
|
|
inscrits_ailleurs = set(list_inscrits_date(formsemestre))
|
2020-09-26 16:19:37 +02:00
|
|
|
|
2024-02-19 19:10:12 +01:00
|
|
|
def set_to_sorted_etud_list(etudset) -> list[Identite]:
|
2020-09-26 16:19:37 +02:00
|
|
|
etuds = [candidats[etudid] for etudid in etudset]
|
2024-02-19 19:10:12 +01:00
|
|
|
etuds.sort(key=lambda e: e.sort_key)
|
2020-09-26 16:19:37 +02:00
|
|
|
return etuds
|
|
|
|
|
|
|
|
if submitted:
|
|
|
|
a_inscrire = etuds_set.intersection(candidats_set) - inscrits_set
|
|
|
|
a_desinscrire = inscrits_set - etuds_set
|
|
|
|
else:
|
|
|
|
a_inscrire = a_desinscrire = []
|
|
|
|
|
|
|
|
if not submitted:
|
2023-01-26 18:29:16 +01:00
|
|
|
H += _build_page(
|
2024-02-19 19:10:12 +01:00
|
|
|
formsemestre,
|
2020-09-26 16:19:37 +02:00
|
|
|
auth_etuds_by_sem,
|
|
|
|
inscrits,
|
|
|
|
candidats_non_inscrits,
|
|
|
|
inscrits_ailleurs,
|
|
|
|
inscrit_groupes=inscrit_groupes,
|
2023-08-31 13:38:17 +02:00
|
|
|
inscrit_parcours=inscrit_parcours,
|
2022-01-18 22:01:30 +01:00
|
|
|
ignore_jury=ignore_jury,
|
2024-10-31 09:20:45 +01:00
|
|
|
with_apo_cols=False,
|
2020-09-26 16:19:37 +02:00
|
|
|
)
|
|
|
|
else:
|
|
|
|
if not dialog_confirmed:
|
|
|
|
# Confirmation
|
|
|
|
if a_inscrire:
|
2023-01-26 18:29:16 +01:00
|
|
|
H.append("<h3>Étudiants à inscrire</h3><ol>")
|
2020-09-26 16:19:37 +02:00
|
|
|
for etud in set_to_sorted_etud_list(a_inscrire):
|
2024-02-19 19:10:12 +01:00
|
|
|
H.append(f"<li>{etud.nomprenom}</li>")
|
2020-09-26 16:19:37 +02:00
|
|
|
H.append("</ol>")
|
|
|
|
a_inscrire_en_double = inscrits_ailleurs.intersection(a_inscrire)
|
|
|
|
if a_inscrire_en_double:
|
|
|
|
H.append("<h3>dont étudiants déjà inscrits:</h3><ul>")
|
|
|
|
for etud in set_to_sorted_etud_list(a_inscrire_en_double):
|
2024-02-19 19:10:12 +01:00
|
|
|
H.append(f'<li class="inscrit-ailleurs">{etud.nomprenom}</li>')
|
2020-09-26 16:19:37 +02:00
|
|
|
H.append("</ul>")
|
|
|
|
if a_desinscrire:
|
2023-01-26 18:29:16 +01:00
|
|
|
H.append("<h3>Étudiants à désinscrire</h3><ol>")
|
2024-02-19 19:10:12 +01:00
|
|
|
a_desinscrire_ident = sorted(
|
2024-08-06 23:18:17 +02:00
|
|
|
(db.session.get(Identite, eid) for eid in a_desinscrire),
|
2024-02-19 19:10:12 +01:00
|
|
|
key=lambda x: x.sort_key,
|
|
|
|
)
|
|
|
|
for etud in a_desinscrire_ident:
|
|
|
|
H.append(f'<li class="desinscription">{etud.nomprenom}</li>')
|
2020-09-26 16:19:37 +02:00
|
|
|
H.append("</ol>")
|
2021-09-27 22:54:58 +02:00
|
|
|
todo = a_inscrire or a_desinscrire
|
|
|
|
if not todo:
|
2020-09-26 16:19:37 +02:00
|
|
|
H.append("""<h3>Il n'y a rien à modifier !</h3>""")
|
|
|
|
H.append(
|
2021-06-02 22:40:34 +02:00
|
|
|
scu.confirm_dialog(
|
2024-02-19 19:10:12 +01:00
|
|
|
dest_url=(
|
|
|
|
"formsemestre_inscr_passage" if todo else "formsemestre_status"
|
|
|
|
),
|
2021-09-27 22:54:58 +02:00
|
|
|
message="<p>Confirmer ?</p>" if todo else "",
|
2020-09-26 16:19:37 +02:00
|
|
|
add_headers=False,
|
|
|
|
cancel_url="formsemestre_inscr_passage?formsemestre_id="
|
2021-08-10 17:12:10 +02:00
|
|
|
+ str(formsemestre_id),
|
2021-09-27 22:54:58 +02:00
|
|
|
OK="Effectuer l'opération" if todo else "",
|
2020-09-26 16:19:37 +02:00
|
|
|
parameters={
|
|
|
|
"formsemestre_id": formsemestre_id,
|
2021-09-27 16:42:14 +02:00
|
|
|
"etuds": ",".join([str(x) for x in etuds]),
|
2020-09-26 16:19:37 +02:00
|
|
|
"inscrit_groupes": inscrit_groupes,
|
2023-08-31 13:38:17 +02:00
|
|
|
"inscrit_parcours": inscrit_parcours,
|
2022-01-18 22:55:33 +01:00
|
|
|
"ignore_jury": ignore_jury,
|
2020-09-26 16:19:37 +02:00
|
|
|
"submitted": 1,
|
|
|
|
},
|
|
|
|
)
|
|
|
|
)
|
|
|
|
else:
|
2024-02-19 19:10:12 +01:00
|
|
|
# check decisions jury ici pour éviter de recontruire le cache
|
|
|
|
# après chaque desinscription
|
|
|
|
sco_formsemestre_inscriptions.check_if_has_decision_jury(
|
|
|
|
formsemestre, a_desinscrire
|
|
|
|
)
|
|
|
|
# check decisions jury ici pour éviter de recontruire le cache
|
|
|
|
# après chaque desinscription
|
|
|
|
sco_formsemestre_inscriptions.check_if_has_decision_jury(
|
|
|
|
formsemestre, a_desinscrire
|
|
|
|
)
|
2023-01-26 18:29:16 +01:00
|
|
|
with sco_cache.DeferredSemCacheManager():
|
|
|
|
# Inscription des étudiants au nouveau semestre:
|
|
|
|
do_inscrit(
|
2024-02-19 19:10:12 +01:00
|
|
|
formsemestre,
|
2023-01-26 18:29:16 +01:00
|
|
|
a_inscrire,
|
|
|
|
inscrit_groupes=inscrit_groupes,
|
2023-08-31 13:38:17 +02:00
|
|
|
inscrit_parcours=inscrit_parcours,
|
2023-01-26 18:29:16 +01:00
|
|
|
)
|
|
|
|
# Désinscriptions:
|
2024-02-19 19:10:12 +01:00
|
|
|
do_desinscrit(formsemestre, a_desinscrire, check_has_dec_jury=False)
|
2020-09-26 16:19:37 +02:00
|
|
|
|
|
|
|
H.append(
|
2023-01-26 18:29:16 +01:00
|
|
|
f"""<h3>Opération effectuée</h3>
|
|
|
|
<ul>
|
|
|
|
<li><a class="stdlink" href="{
|
|
|
|
url_for("notes.formsemestre_inscr_passage",
|
|
|
|
scodoc_dept=g.scodoc_dept, formsemestre_id=formsemestre_id)
|
|
|
|
}">Continuer les inscriptions</a>
|
|
|
|
</li>
|
|
|
|
<li><a class="stdlink" href="{
|
|
|
|
url_for("notes.formsemestre_status",
|
|
|
|
scodoc_dept=g.scodoc_dept, formsemestre_id=formsemestre_id)
|
|
|
|
}">Tableau de bord du semestre</a>
|
|
|
|
</li>"""
|
2020-09-26 16:19:37 +02:00
|
|
|
)
|
2021-08-19 10:28:35 +02:00
|
|
|
partition = sco_groups.formsemestre_get_main_partition(formsemestre_id)
|
2020-09-26 16:19:37 +02:00
|
|
|
if (
|
|
|
|
partition["partition_id"]
|
2021-08-19 10:28:35 +02:00
|
|
|
!= sco_groups.formsemestre_get_main_partition(formsemestre_id)[
|
2020-09-26 16:19:37 +02:00
|
|
|
"partition_id"
|
|
|
|
]
|
|
|
|
): # il y a au moins une vraie partition
|
|
|
|
H.append(
|
2021-08-16 08:33:12 +02:00
|
|
|
f"""<li><a class="stdlink" href="{
|
2023-07-21 09:25:39 +02:00
|
|
|
url_for("scolar.partition_editor", scodoc_dept=g.scodoc_dept,
|
|
|
|
formsemestre_id=formsemestre_id)
|
|
|
|
}">Répartir les groupes de {partition["partition_name"]}</a></li>
|
|
|
|
"""
|
2020-09-26 16:19:37 +02:00
|
|
|
)
|
|
|
|
|
2024-08-23 23:16:49 +02:00
|
|
|
return render_template(
|
2024-10-31 09:20:45 +01:00
|
|
|
"formsemestre/synchro_etuds.j2",
|
|
|
|
title="Passage des étudiants",
|
|
|
|
content="\n".join(H),
|
2024-08-23 23:16:49 +02:00
|
|
|
)
|
2020-09-26 16:19:37 +02:00
|
|
|
|
|
|
|
|
2023-01-26 18:29:16 +01:00
|
|
|
def _build_page(
|
2024-02-19 19:10:12 +01:00
|
|
|
formsemestre: FormSemestre,
|
2020-09-26 16:19:37 +02:00
|
|
|
auth_etuds_by_sem,
|
|
|
|
inscrits,
|
|
|
|
candidats_non_inscrits,
|
|
|
|
inscrits_ailleurs,
|
|
|
|
inscrit_groupes=False,
|
2023-08-31 13:38:17 +02:00
|
|
|
inscrit_parcours=False,
|
2022-01-18 22:01:30 +01:00
|
|
|
ignore_jury=False,
|
2024-10-31 09:20:45 +01:00
|
|
|
with_apo_cols: bool = True,
|
2020-09-26 16:19:37 +02:00
|
|
|
):
|
|
|
|
inscrit_groupes = int(inscrit_groupes)
|
2023-08-31 13:38:17 +02:00
|
|
|
inscrit_parcours = int(inscrit_parcours)
|
2022-01-18 22:01:30 +01:00
|
|
|
ignore_jury = int(ignore_jury)
|
2020-09-26 16:19:37 +02:00
|
|
|
if inscrit_groupes:
|
|
|
|
inscrit_groupes_checked = " checked"
|
|
|
|
else:
|
|
|
|
inscrit_groupes_checked = ""
|
2023-08-31 13:38:17 +02:00
|
|
|
if inscrit_parcours:
|
|
|
|
inscrit_parcours_checked = " checked"
|
|
|
|
else:
|
|
|
|
inscrit_parcours_checked = ""
|
2022-01-18 22:01:30 +01:00
|
|
|
if ignore_jury:
|
|
|
|
ignore_jury_checked = " checked"
|
|
|
|
else:
|
|
|
|
ignore_jury_checked = ""
|
2020-09-26 16:19:37 +02:00
|
|
|
H = [
|
2024-08-16 01:11:06 +02:00
|
|
|
f"""
|
|
|
|
<h2 class="formsemestre">Passages dans le semestre</h2>
|
|
|
|
<form name="f" method="post" action="{request.base_url}">
|
2023-01-26 18:29:16 +01:00
|
|
|
|
2024-02-19 19:10:12 +01:00
|
|
|
<input type="hidden" name="formsemestre_id" value="{formsemestre.id}"/>
|
2023-01-26 18:29:16 +01:00
|
|
|
|
|
|
|
<input type="submit" name="submitted" value="Appliquer les modifications"/>
|
|
|
|
<a href="#help">aide</a>
|
|
|
|
|
|
|
|
<input name="inscrit_groupes" type="checkbox" value="1"
|
2023-08-31 13:38:17 +02:00
|
|
|
{inscrit_groupes_checked}>inscrire aux mêmes groupes (y compris parcours)</input>
|
|
|
|
|
|
|
|
<input name="inscrit_parcours" type="checkbox" value="1"
|
|
|
|
{inscrit_parcours_checked}>inscrire aux mêmes parcours</input>
|
2023-01-26 18:29:16 +01:00
|
|
|
|
|
|
|
<input name="ignore_jury" type="checkbox" value="1" onchange="document.f.submit()"
|
|
|
|
{ignore_jury_checked}>inclure tous les étudiants (même sans décision de jury)</input>
|
|
|
|
|
2023-08-31 13:38:17 +02:00
|
|
|
<div class="pas_recap">Actuellement <span id="nbinscrits">{len(inscrits)}</span>
|
|
|
|
inscrits et {len(candidats_non_inscrits)} candidats supplémentaires.
|
2023-01-26 18:29:16 +01:00
|
|
|
</div>
|
|
|
|
|
2023-08-31 13:38:17 +02:00
|
|
|
<div>{scu.EMO_WARNING}
|
2024-02-19 19:10:12 +01:00
|
|
|
<em>Seuls les semestres dont la date de fin est proche de la date de début
|
2024-04-02 23:37:23 +02:00
|
|
|
de ce semestre ({formsemestre.date_debut.strftime(scu.DATE_FMT)}) sont pris en
|
2023-08-31 13:38:17 +02:00
|
|
|
compte.</em>
|
|
|
|
</div>
|
2024-10-31 09:20:45 +01:00
|
|
|
{etuds_select_boxes(auth_etuds_by_sem, inscrits_ailleurs, with_apo_cols=with_apo_cols)}
|
2023-01-26 18:29:16 +01:00
|
|
|
|
|
|
|
<input type="submit" name="submitted" value="Appliquer les modifications"/>
|
|
|
|
|
2024-02-19 19:10:12 +01:00
|
|
|
{formsemestre_inscr_passage_help(formsemestre)}
|
2023-01-26 18:29:16 +01:00
|
|
|
|
|
|
|
</form>
|
|
|
|
""",
|
2020-09-26 16:19:37 +02:00
|
|
|
]
|
|
|
|
|
2023-01-26 18:29:16 +01:00
|
|
|
# Semestres sans étudiants autorisés
|
2020-09-26 16:19:37 +02:00
|
|
|
empty_sems = []
|
|
|
|
for formsemestre_id in auth_etuds_by_sem.keys():
|
|
|
|
if not auth_etuds_by_sem[formsemestre_id]["etuds"]:
|
|
|
|
empty_sems.append(auth_etuds_by_sem[formsemestre_id]["infos"])
|
|
|
|
if empty_sems:
|
|
|
|
H.append(
|
|
|
|
"""<div class="pas_empty_sems"><h3>Autres semestres sans candidats :</h3><ul>"""
|
|
|
|
)
|
|
|
|
for infos in empty_sems:
|
2023-01-26 18:29:16 +01:00
|
|
|
H.append(
|
|
|
|
"""<li><a class="stdlink" href="%(title_target)s">%(title)s</a></li>"""
|
|
|
|
% infos
|
|
|
|
)
|
2020-09-26 16:19:37 +02:00
|
|
|
H.append("""</ul></div>""")
|
|
|
|
|
|
|
|
return H
|
|
|
|
|
|
|
|
|
2024-02-19 19:10:12 +01:00
|
|
|
def formsemestre_inscr_passage_help(formsemestre: FormSemestre):
|
2023-08-31 13:38:17 +02:00
|
|
|
"texte d'aide en bas de la page passage des étudiants"
|
2023-01-24 00:35:15 +01:00
|
|
|
return f"""<div class="pas_help"><h3><a name="help">Explications</a></h3>
|
2020-09-26 16:19:37 +02:00
|
|
|
<p>Cette page permet d'inscrire des étudiants dans le semestre destination
|
|
|
|
<a class="stdlink"
|
2023-01-24 00:35:15 +01:00
|
|
|
href="{
|
2024-02-19 19:10:12 +01:00
|
|
|
url_for("notes.formsemestre_status",
|
|
|
|
scodoc_dept=g.scodoc_dept, formsemestre_id=formsemestre.id )
|
|
|
|
}">{formsemestre.titre_annee()}</a>,
|
2020-09-26 16:19:37 +02:00
|
|
|
et d'en désincrire si besoin.
|
|
|
|
</p>
|
2023-08-31 13:38:17 +02:00
|
|
|
<p>Les étudiants sont groupés par semestre d'origine. Ceux qui sont en caractères
|
2024-02-19 19:10:12 +01:00
|
|
|
<span class="deja-inscrit">gras</span> sont déjà inscrits dans le semestre destination.
|
|
|
|
Ceux qui sont en <span class="inscrit-ailleurs">gras et en rouge</span> sont inscrits
|
2023-08-31 13:38:17 +02:00
|
|
|
dans un <em>autre</em> semestre.
|
|
|
|
</p>
|
|
|
|
<p>Au départ, les étudiants déjà inscrits sont sélectionnés; vous pouvez ajouter
|
|
|
|
d'autres étudiants à inscrire dans le semestre destination.
|
|
|
|
</p>
|
|
|
|
|
|
|
|
<p>Si vous dé-selectionnez un étudiant déjà inscrit (en gras), il sera désinscrit.
|
|
|
|
</p>
|
|
|
|
|
|
|
|
<p>Le bouton <em>inscrire aux mêmes groupes</em> ne prend en compte que les groupes
|
|
|
|
qui existent dans les deux semestres: pensez à créer les partitions et groupes que
|
|
|
|
vous souhaitez conserver <b>avant</b> d'inscrire les étudiants.
|
|
|
|
</p>
|
|
|
|
|
|
|
|
<p>Les parcours de BUT sont gérés comme des groupes de la partition parcours: si on
|
|
|
|
conserve les groupes, on conserve les parcours (là aussi, pensez à les cocher dans
|
|
|
|
<a class="stdlink" href="{
|
|
|
|
url_for("notes.formsemestre_editwithmodules", scodoc_dept=g.scodoc_dept,
|
2024-02-19 19:10:12 +01:00
|
|
|
formsemestre_id=formsemestre.id )
|
2023-08-31 13:38:17 +02:00
|
|
|
}">modifier le semestre</a> avant de faire passer les étudiants).
|
|
|
|
</a>
|
|
|
|
|
|
|
|
<p class="help">Aucune action ne sera effectuée si vous n'appuyez pas sur le bouton
|
|
|
|
"Appliquer les modifications" !
|
2023-01-24 00:35:15 +01:00
|
|
|
</p>
|
|
|
|
</div>
|
|
|
|
"""
|
2020-09-26 16:19:37 +02:00
|
|
|
|
|
|
|
|
|
|
|
def etuds_select_boxes(
|
|
|
|
auth_etuds_by_cat,
|
2024-08-16 01:11:06 +02:00
|
|
|
inscrits_ailleurs: dict = None,
|
2020-09-26 16:19:37 +02:00
|
|
|
sel_inscrits=True,
|
|
|
|
show_empty_boxes=False,
|
|
|
|
export_cat_xls=None,
|
|
|
|
base_url="",
|
|
|
|
read_only=False,
|
2024-10-31 09:20:45 +01:00
|
|
|
with_apo_cols: bool = True,
|
2020-09-26 16:19:37 +02:00
|
|
|
):
|
|
|
|
"""Boites pour selection étudiants par catégorie
|
|
|
|
auth_etuds_by_cat = { category : { 'info' : {}, 'etuds' : ... }
|
|
|
|
inscrits_ailleurs =
|
2020-12-02 01:00:23 +01:00
|
|
|
sel_inscrits=
|
2020-09-26 16:19:37 +02:00
|
|
|
export_cat_xls =
|
|
|
|
"""
|
2024-08-16 01:11:06 +02:00
|
|
|
inscrits_ailleurs = inscrits_ailleurs or {}
|
2020-09-26 16:19:37 +02:00
|
|
|
if export_cat_xls:
|
2021-08-21 00:24:51 +02:00
|
|
|
return etuds_select_box_xls(auth_etuds_by_cat[export_cat_xls])
|
2020-09-26 16:19:37 +02:00
|
|
|
|
|
|
|
H = [
|
2024-10-31 09:20:45 +01:00
|
|
|
"""
|
2020-09-26 16:19:37 +02:00
|
|
|
<div class="etuds_select_boxes">"""
|
|
|
|
] # "
|
2021-09-25 10:43:06 +02:00
|
|
|
# Élimine les boites vides:
|
|
|
|
auth_etuds_by_cat = {
|
|
|
|
k: auth_etuds_by_cat[k]
|
|
|
|
for k in auth_etuds_by_cat
|
|
|
|
if auth_etuds_by_cat[k]["etuds"]
|
|
|
|
}
|
2020-09-26 16:19:37 +02:00
|
|
|
for src_cat in auth_etuds_by_cat.keys():
|
|
|
|
infos = auth_etuds_by_cat[src_cat]["infos"]
|
|
|
|
infos["comment"] = infos.get("comment", "") # commentaire dans sous-titre boite
|
|
|
|
etuds = auth_etuds_by_cat[src_cat]["etuds"]
|
2021-07-09 23:19:30 +02:00
|
|
|
etuds.sort(key=itemgetter("nom"))
|
2020-09-26 16:19:37 +02:00
|
|
|
with_checkbox = (not read_only) and auth_etuds_by_cat[src_cat]["infos"].get(
|
|
|
|
"with_checkbox", True
|
|
|
|
)
|
|
|
|
if etuds or show_empty_boxes:
|
|
|
|
infos["nbetuds"] = len(etuds)
|
2024-10-30 22:11:39 +01:00
|
|
|
xls_url = (
|
|
|
|
scu.build_url_query(base_url, export_cat_xls=src_cat)
|
|
|
|
if base_url and etuds
|
|
|
|
else ""
|
2020-09-26 16:19:37 +02:00
|
|
|
)
|
|
|
|
H.append(
|
2024-10-30 22:11:39 +01:00
|
|
|
etuds_select_box(
|
|
|
|
etuds,
|
|
|
|
infos,
|
|
|
|
with_checkbox=with_checkbox,
|
|
|
|
sel_inscrits=sel_inscrits,
|
|
|
|
xls_url=xls_url,
|
|
|
|
inscrits_ailleurs=inscrits_ailleurs,
|
2024-10-31 09:20:45 +01:00
|
|
|
with_apo_cols=with_apo_cols,
|
2020-09-26 16:19:37 +02:00
|
|
|
)
|
2024-10-30 22:11:39 +01:00
|
|
|
)
|
2020-09-26 16:19:37 +02:00
|
|
|
|
|
|
|
H.append("</div>")
|
|
|
|
return "\n".join(H)
|
|
|
|
|
|
|
|
|
2024-10-30 22:11:39 +01:00
|
|
|
def etuds_select_box(
|
|
|
|
etuds: list[dict],
|
|
|
|
infos: dict,
|
|
|
|
with_checkbox: bool = True,
|
|
|
|
sel_inscrits: bool = True,
|
|
|
|
xls_url: str = "",
|
|
|
|
inscrits_ailleurs: set = None,
|
2024-10-31 09:20:45 +01:00
|
|
|
with_apo_cols: bool = True,
|
2024-10-30 22:11:39 +01:00
|
|
|
) -> str:
|
|
|
|
"""HTML pour une "boite" avec une liste d'étudiants à sélectionner"""
|
|
|
|
inscrits_ailleurs = inscrits_ailleurs or {}
|
|
|
|
box_id = infos["id"]
|
|
|
|
H = []
|
|
|
|
H.append(
|
|
|
|
f"""<div class="pas_sembox" id="{box_id}">
|
|
|
|
<div class="pas_sembox_title"><a href="{infos['title_target']}" """
|
|
|
|
)
|
|
|
|
help_txt = infos.get("help")
|
|
|
|
if help_txt: # bubble
|
|
|
|
H.append(f'title="{help_txt}"')
|
|
|
|
H.append(
|
|
|
|
""">%(title)s</a></div>
|
|
|
|
<div class="pas_sembox_subtitle">(%(nbetuds)d étudiants%(comment)s)"""
|
|
|
|
% infos
|
|
|
|
)
|
|
|
|
if with_checkbox:
|
|
|
|
H.append(
|
|
|
|
f""" (Select.
|
|
|
|
<a href="#" class="stdlink" onclick="sem_select('{box_id}', true);">tous</a>
|
|
|
|
<a href="#" class="stdlink" onclick="sem_select('{box_id}', false );">aucun</a>"""
|
|
|
|
)
|
|
|
|
if sel_inscrits:
|
|
|
|
H.append(
|
2024-10-30 23:08:35 +01:00
|
|
|
f"""<a href="#"
|
|
|
|
class="stdlink" onclick="sem_select_inscrits('{box_id}');"
|
|
|
|
>inscrits</a>"""
|
2024-10-30 22:11:39 +01:00
|
|
|
)
|
|
|
|
if with_checkbox or sel_inscrits:
|
|
|
|
H.append(")")
|
|
|
|
if xls_url:
|
|
|
|
H.append(f'<a href="{xls_url}">{scu.ICON_XLS}</a> ')
|
|
|
|
H.append("</div>")
|
2024-10-31 09:20:45 +01:00
|
|
|
checkbox_title = """<th class="no-sort"></th>""" if with_checkbox else ""
|
|
|
|
ths = (
|
|
|
|
f"<th>Étape</th>{checkbox_title}<th>Nom</th><th>Paiement</th><th>Finalisé</th>"
|
|
|
|
if with_apo_cols
|
|
|
|
else f"{checkbox_title}<th>Nom</th>"
|
|
|
|
)
|
2024-10-30 23:08:35 +01:00
|
|
|
H.append(
|
|
|
|
f"""<table class="etuds-box">
|
|
|
|
<thead>
|
|
|
|
<tr>
|
2024-10-31 09:20:45 +01:00
|
|
|
{ths}
|
2024-10-30 23:08:35 +01:00
|
|
|
</tr>
|
|
|
|
</thead>
|
|
|
|
<tbody>
|
|
|
|
"""
|
|
|
|
)
|
2024-10-30 22:11:39 +01:00
|
|
|
for etud in etuds:
|
|
|
|
is_inscrit = etud.get("inscrit", False)
|
|
|
|
extra_class = (
|
|
|
|
"deja-inscrit"
|
|
|
|
if is_inscrit
|
|
|
|
else ("inscrit-ailleurs" if etud["etudid"] in inscrits_ailleurs else "")
|
|
|
|
)
|
|
|
|
H.append(
|
|
|
|
_etud_row(
|
|
|
|
etud,
|
|
|
|
with_checkbox=with_checkbox,
|
|
|
|
checkbox_name=infos.get("checkbox_name", "etuds"),
|
|
|
|
etud_key=infos.get("etud_key", "etudid"),
|
|
|
|
is_inscrit=is_inscrit,
|
|
|
|
extra_class=extra_class,
|
2024-10-31 09:20:45 +01:00
|
|
|
with_apo_cols=with_apo_cols,
|
2024-10-30 22:11:39 +01:00
|
|
|
)
|
|
|
|
)
|
2024-10-30 23:08:35 +01:00
|
|
|
H.append(
|
|
|
|
"""</tbody>
|
|
|
|
</table>"""
|
|
|
|
)
|
2024-10-30 22:11:39 +01:00
|
|
|
|
|
|
|
H.append("</div>")
|
|
|
|
return "\n".join(H)
|
|
|
|
|
|
|
|
|
|
|
|
def _etud_row(
|
|
|
|
etud: dict,
|
|
|
|
with_checkbox: bool = True,
|
|
|
|
checkbox_name: str = "etuds",
|
|
|
|
etud_key: str = "",
|
|
|
|
is_inscrit: bool = False,
|
|
|
|
extra_class: str = "",
|
2024-10-31 09:20:45 +01:00
|
|
|
with_apo_cols: bool = True,
|
2024-10-30 22:11:39 +01:00
|
|
|
) -> str:
|
|
|
|
"""HTML 'row' for this etud"""
|
|
|
|
H = []
|
|
|
|
nomprenom = scu.format_nomprenom(etud)
|
|
|
|
if etud["etudid"]:
|
|
|
|
elink = f"""<a id="{etud['etudid']}" class="discretelink etudinfo {extra_class}"
|
|
|
|
href="{ url_for(
|
|
|
|
'scolar.fiche_etud',
|
|
|
|
scodoc_dept=g.scodoc_dept,
|
|
|
|
etudid=etud['etudid'],
|
|
|
|
)
|
|
|
|
}">{nomprenom}</a>
|
|
|
|
"""
|
|
|
|
else:
|
|
|
|
# ce n'est pas un etudiant ScoDoc
|
|
|
|
elink = nomprenom
|
|
|
|
|
2024-10-30 23:08:35 +01:00
|
|
|
checkbox_cell = (
|
|
|
|
f"""<td><input type="checkbox" name="{checkbox_name}:list"
|
|
|
|
value="{etud[etud_key]}" {'checked="checked"' if is_inscrit else ''}>
|
|
|
|
</td>
|
|
|
|
"""
|
|
|
|
if with_checkbox
|
|
|
|
else ""
|
|
|
|
)
|
|
|
|
paiement = etud.get("paiementinscription", True)
|
|
|
|
datefinalisation = etud.get("datefinalisationinscription")
|
2024-10-31 09:20:45 +01:00
|
|
|
if with_apo_cols:
|
|
|
|
H.append(
|
|
|
|
f"""
|
|
|
|
<tr class="{extra_class}">
|
|
|
|
<td class="etape">{etud.get("etape", "") or ""}</td>
|
|
|
|
{checkbox_cell}
|
|
|
|
<td data-order="{etud.get("nom", "").upper()}">{elink}</td>
|
|
|
|
<td class="paiement {'' if paiement else 'paspaye'}">{
|
|
|
|
'' if paiement else 'non paiement'
|
|
|
|
}</td>
|
|
|
|
<td class="finalise" data-order="{
|
|
|
|
datefinalisation.isoformat() if datefinalisation else ''
|
|
|
|
}">{"inscription finalisée le " + datefinalisation.strftime(scu.DATE_FMT)
|
|
|
|
if datefinalisation else "" }
|
|
|
|
</td>
|
|
|
|
</tr>
|
|
|
|
"""
|
|
|
|
)
|
|
|
|
else: # juste checkbox et nom
|
|
|
|
H.append(
|
|
|
|
f"""
|
|
|
|
<tr class="{extra_class}">
|
|
|
|
{checkbox_cell}
|
|
|
|
<td data-order="{etud.get("nom", "").upper()}">{elink}</td>
|
|
|
|
</tr>
|
|
|
|
"""
|
|
|
|
)
|
2024-10-30 22:11:39 +01:00
|
|
|
|
|
|
|
return "\n".join(H)
|
|
|
|
|
|
|
|
|
2021-08-21 00:24:51 +02:00
|
|
|
def etuds_select_box_xls(src_cat):
|
2020-09-26 16:19:37 +02:00
|
|
|
"export a box to excel"
|
|
|
|
etuds = src_cat["etuds"]
|
2024-10-30 12:18:53 +01:00
|
|
|
columns_ids = [
|
|
|
|
"etudid",
|
|
|
|
"ine",
|
|
|
|
"nip",
|
|
|
|
"civilite_str",
|
|
|
|
"nom",
|
|
|
|
"prenom",
|
|
|
|
"etape",
|
|
|
|
"paiementinscription_str",
|
|
|
|
"datefinalisationinscription",
|
|
|
|
]
|
|
|
|
titles = {x: x for x in columns_ids} | {
|
|
|
|
"paiementinscription_str": "Paiement inscr.",
|
|
|
|
"datefinalisationinscription": "Finalisation inscr.",
|
|
|
|
}
|
2020-09-26 16:19:37 +02:00
|
|
|
for e in etuds:
|
|
|
|
if not e.get("paiementinscription", True):
|
|
|
|
e["paiementinscription_str"] = "NON"
|
|
|
|
else:
|
|
|
|
e["paiementinscription_str"] = "-"
|
2024-10-30 12:18:53 +01:00
|
|
|
# si e est un étudiant Apo, on a nip et ine
|
|
|
|
# mais si e est ScoDoc, on a code_nip et code_ine:
|
|
|
|
e["nip"] = e.get("nip", e.get("code_nip"))
|
|
|
|
e["ine"] = e.get("ine", e.get("code_ine"))
|
|
|
|
# Pour excel, datefinalisationinscription doit être datetime
|
|
|
|
dat = e.get("datefinalisationinscription")
|
|
|
|
if isinstance(dat, datetime.date):
|
|
|
|
e["datefinalisationinscription"] = datetime.datetime.combine(
|
|
|
|
dat, datetime.time.min
|
|
|
|
)
|
2020-09-26 16:19:37 +02:00
|
|
|
tab = GenTable(
|
|
|
|
caption="%(title)s. %(help)s" % src_cat["infos"],
|
2024-05-22 00:06:30 +02:00
|
|
|
columns_ids=columns_ids,
|
2021-07-28 17:03:54 +02:00
|
|
|
preferences=sco_preferences.SemPreferences(),
|
2024-05-22 00:06:30 +02:00
|
|
|
rows=etuds,
|
|
|
|
table_id="etuds_select_box_xls",
|
|
|
|
titles=titles,
|
2020-09-26 16:19:37 +02:00
|
|
|
)
|
2024-07-19 18:03:24 +02:00
|
|
|
return tab.excel()
|