forked from ScoDoc/ScoDoc
[WIP] Assiduité : corrections saisie_assiduites_hebdo
This commit is contained in:
parent
eb88a8ca83
commit
f94998f66b
@ -57,14 +57,10 @@
|
||||
text-align: center;
|
||||
}
|
||||
|
||||
#tableau-periode {
|
||||
overflow-x: auto;
|
||||
max-width: 100%;
|
||||
}
|
||||
|
||||
table {
|
||||
border-collapse: collapse;
|
||||
width: 100%;
|
||||
max-width: 1600px;
|
||||
position: relative;
|
||||
}
|
||||
|
||||
@ -99,7 +95,7 @@
|
||||
z-index: 1;
|
||||
}
|
||||
|
||||
td.active>.rbtn:not(:checked)::before {
|
||||
.rbtn:not(:checked)::before {
|
||||
opacity: 0.5;
|
||||
}
|
||||
|
||||
@ -128,13 +124,6 @@
|
||||
input.checked = false;
|
||||
}
|
||||
});
|
||||
|
||||
if(!target.checked && parent.classList.contains("active")){
|
||||
parent.classList.remove("active");
|
||||
}else{
|
||||
parent.classList.add("active");
|
||||
}
|
||||
|
||||
});
|
||||
});
|
||||
|
||||
|
@ -1989,82 +1989,75 @@ def traitement_justificatifs():
|
||||
|
||||
@bp.route("signal_assiduites_hebdo")
|
||||
@scodoc
|
||||
@permission_required(Permission.AbsChange)
|
||||
@permission_required(Permission.ScoView)
|
||||
def signal_assiduites_hebdo():
|
||||
"""
|
||||
signal_assiduites_hebdo
|
||||
|
||||
paramètres obligatoires :
|
||||
- formsemestre_id : id du formsemestre
|
||||
- semaine : date semaine (iso 8601 -> 20XX-WXX)
|
||||
- week : date semaine (iso 8601 -> 20XX-WXX)
|
||||
- groups_id : id des groupes (séparés par des virgules -> 1,2,3)
|
||||
|
||||
paramètres optionnels :
|
||||
- moduleimpl_id : id du moduleimpl (par défaut None)
|
||||
|
||||
|
||||
Permissions :
|
||||
- ScoView -> page en lecture seule
|
||||
- AbsChange -> page en lecture/écriture
|
||||
"""
|
||||
|
||||
# Récupération des paramètres
|
||||
moduleimpl_id: int = request.args.get("moduleimpl_id", None)
|
||||
semaine: str = request.args.get("semaine", None)
|
||||
group_ids: list[int] = request.args.get("group_ids", None)
|
||||
week: str = request.args.get("week", None)
|
||||
group_ids: str = request.args.get("group_ids", "") # ex: "1,2,3"
|
||||
formsemestre_id: int = request.args.get("formsemestre_id", -1)
|
||||
|
||||
# Vérification des paramètres
|
||||
if semaine is None or group_ids is None or formsemestre_id is None:
|
||||
if week is None or group_ids == "" or formsemestre_id == -1:
|
||||
raise ScoValueError("Paramètres manquants", dest_url=request.referrer)
|
||||
|
||||
# Récupération du moduleimpl
|
||||
moduleimpl: ModuleImpl | None = ModuleImpl.query.get(moduleimpl_id)
|
||||
module_text: str = "Non spécifié"
|
||||
if moduleimpl is not None:
|
||||
module_text = f"{moduleimpl.code} {moduleimpl.titre}"
|
||||
else:
|
||||
if moduleimpl_id == "autre":
|
||||
module_text = "Autre module (pas dans la liste)"
|
||||
moduleimpl_id = None if moduleimpl_id != "autre" else moduleimpl_id
|
||||
try:
|
||||
moduleimpl_id: int = int(moduleimpl_id)
|
||||
except (ValueError, TypeError):
|
||||
moduleimpl_id: str | None = None if moduleimpl_id != "autre" else moduleimpl_id
|
||||
|
||||
# Récupération du formsemestre
|
||||
formsemestre: FormSemestre = FormSemestre.get_formsemestre(formsemestre_id)
|
||||
|
||||
# vérification semaine dans format iso 8601 et formsemestre
|
||||
try:
|
||||
lundi_semaine = datetime.datetime.strptime(semaine + "-1", "%G-W%V-%u")
|
||||
if (
|
||||
lundi_semaine.date() < formsemestre.date_debut
|
||||
or lundi_semaine.date() > formsemestre.date_fin
|
||||
):
|
||||
raise ScoValueError(
|
||||
"Semaine en dehors du semestre", dest_url=request.referrer
|
||||
)
|
||||
# Vérification semaine dans format iso 8601 et formsemestre
|
||||
regex_iso8601 = r"^\d{4}-W\d{2}$"
|
||||
if not re.match(regex_iso8601, week):
|
||||
raise ScoValueError("Semaine invalide", dest_url=request.referrer)
|
||||
|
||||
except (ValueError, TypeError) as exc:
|
||||
raise ScoValueError("Semaine invalide", dest_url=request.referrer) from exc
|
||||
except ScoValueError as exc:
|
||||
raise exc
|
||||
fs_deb_iso8601 = formsemestre.date_debut.strftime("%Y-W%W")
|
||||
fs_fin_iso8601 = formsemestre.date_fin.strftime("%Y-W%W")
|
||||
|
||||
etudiants: list[Identite] = []
|
||||
# Utilisation de la propriété de la norme iso 8601
|
||||
# les chaines sont triables par ordre alphanumérique croissant
|
||||
# et produiront le même ordre que les dates par ordre chronologique croissant
|
||||
if week < fs_deb_iso8601 or week > fs_fin_iso8601:
|
||||
raise ScoValueError("Semaine hors du semestre", dest_url=request.referrer)
|
||||
|
||||
# Vérification des groupes
|
||||
if group_ids is None:
|
||||
group_ids = []
|
||||
else:
|
||||
group_ids = group_ids.split(",")
|
||||
map(str, group_ids)
|
||||
group_ids = group_ids.split(",") if group_ids != "" else []
|
||||
|
||||
groups_infos = sco_groups_view.DisplayedGroupsInfos(
|
||||
group_ids, formsemestre_id=formsemestre.id, select_all_when_unspecified=True
|
||||
)
|
||||
if not groups_infos.members:
|
||||
return (
|
||||
html_sco_header.sco_header(page_title="Assiduité: saisie hébdomadaire")
|
||||
html_sco_header.sco_header(page_title="Assiduité: saisie hebdomadaire")
|
||||
+ "<h3>Aucun étudiant ! </h3>"
|
||||
+ html_sco_header.sco_footer()
|
||||
)
|
||||
|
||||
# Récupération des étudiants
|
||||
etudiants.extend(
|
||||
[Identite.get_etud(etudid=m["etudid"]) for m in groups_infos.members]
|
||||
)
|
||||
etudiants = list(sorted(etudiants, key=lambda etud: etud.sort_key))
|
||||
etudiants: list[Identite] = [
|
||||
Identite.get_etud(etudid=m["etudid"]) for m in groups_infos.members
|
||||
]
|
||||
|
||||
if groups_infos.tous_les_etuds_du_sem:
|
||||
gr_tit = "en"
|
||||
@ -2077,10 +2070,11 @@ def signal_assiduites_hebdo():
|
||||
grp + ' <span class="fontred">' + groups_infos.groups_titles + "</span>"
|
||||
)
|
||||
|
||||
# TODO vérif perm AbsChange -> readonly
|
||||
|
||||
return render_template(
|
||||
"assiduites/pages/signal_assiduites_hebdo.j2",
|
||||
gr=gr_tit,
|
||||
module=module_text,
|
||||
etudiants=etudiants,
|
||||
moduleimpl_select=_module_selector(
|
||||
formsemestre=formsemestre, moduleimpl_id=moduleimpl_id
|
||||
|
Loading…
Reference in New Issue
Block a user