From e963ca52f5d91a40f781deb260c66da7d935dd6f Mon Sep 17 00:00:00 2001
From: Emmanuel Viennet
Date: Tue, 4 Jul 2023 08:23:09 +0200
Subject: [PATCH 01/13] =?UTF-8?q?Fix:=20=C3=A9dition=20validations=20ant?=
=?UTF-8?q?=C3=A9rieures=20lorsqu'il=20y=20a=20des=20validations=20sans=20?=
=?UTF-8?q?semestres?=
MIME-Version: 1.0
Content-Type: text/plain; charset=UTF-8
Content-Transfer-Encoding: 8bit
---
app/but/jury_but.py | 2 +-
app/scodoc/sco_formsemestre_validation.py | 7 +++++--
app/scodoc/sco_semset.py | 2 +-
sco_version.py | 2 +-
4 files changed, 8 insertions(+), 5 deletions(-)
diff --git a/app/but/jury_but.py b/app/but/jury_but.py
index 1ec6eeeaf..02f18dffa 100644
--- a/app/but/jury_but.py
+++ b/app/but/jury_but.py
@@ -355,7 +355,7 @@ class DecisionsProposeesAnnee(DecisionsProposees):
# Reste à attribuer ADM, ADJ, PASD, PAS1NCI, RED, NAR
plural = self.nb_validables > 1
explanation += f"""{self.nb_validables} niveau{"x" if plural else ""} validable{
- "s" if plural else ""} sur {self.nb_competences}"""
+ "s" if plural else ""} de droit sur {self.nb_competences}"""
if self.admis:
self.codes = [sco_codes.ADM] + self.codes
# elif not self.jury_annuel:
diff --git a/app/scodoc/sco_formsemestre_validation.py b/app/scodoc/sco_formsemestre_validation.py
index f8ce98471..6460fb4f9 100644
--- a/app/scodoc/sco_formsemestre_validation.py
+++ b/app/scodoc/sco_formsemestre_validation.py
@@ -31,6 +31,7 @@ import time
import flask
from flask import url_for, flash, g, request
+from flask_login import current_user
import sqlalchemy as sa
from app.models.etudiants import Identite
@@ -66,7 +67,7 @@ from app.scodoc.sco_cursus_dut import etud_est_inscrit_ue
from app.scodoc import sco_photos
from app.scodoc import sco_preferences
from app.scodoc import sco_pv_dict
-
+from app.scodoc.sco_permissions import Permission
# ------------------------------------------------------------------------------------
def formsemestre_validation_etud_form(
@@ -1288,7 +1289,9 @@ def _get_etud_ue_cap_html(etud: Identite, formsemestre: FormSemestre) -> str:
if validation.semestre_id is not None:
origine += f" (S{validation.semestre_id})"
H.append(f"""{validation.html()}""")
- if validation.formsemestre.can_edit_jury():
+ if (validation.formsemestre and validation.formsemestre.can_edit_jury()) or (
+ current_user and current_user.has_permission(Permission.ScoEtudInscrit)
+ ):
H.append(
f"""
+ """,
]
tf = TrivialFormulator(
@@ -1429,23 +1428,24 @@ def groups_auto_repartition(partition_id=None):
# form submission
log(
"groups_auto_repartition( partition_id=%s partition_name=%s"
- % (partition_id, partition["partition_name"])
+ % (partition_id, partition.partition_name)
)
groupNames = tf[2]["groupNames"]
- group_names = sorted(set([x.strip() for x in groupNames.split(",")]))
+ group_names = sorted({x.strip() for x in groupNames.split(",")})
# Détruit les groupes existant de cette partition
- for old_group in get_partition_groups(partition):
- group_delete(old_group["group_id"])
+ for group in partition.groups:
+ db.session.delete(group)
+ db.session.commit()
# Crée les nouveaux groupes
groups = []
for group_name in group_names:
if group_name.strip():
- groups.append(create_group(partition_id, group_name))
+ groups.append(partition.create_group(group_name))
#
nt: NotesTableCompat = res_sem.load_formsemestre_results(formsemestre)
identdict = nt.identdict
# build: { civilite : liste etudids trie par niveau croissant }
- civilites = set([x["civilite"] for x in identdict.values()])
+ civilites = {x["civilite"] for x in identdict.values()}
listes = {}
for civilite in civilites:
listes[civilite] = [
@@ -1460,14 +1460,17 @@ def groups_auto_repartition(partition_id=None):
igroup = 0
nbgroups = len(groups)
while n > 0:
+ log(f"n={n}")
for civilite in civilites:
+ log(f"civilite={civilite}")
if len(listes[civilite]):
n -= 1
etudid = listes[civilite].pop()[1]
group = groups[igroup]
igroup = (igroup + 1) % nbgroups
+ log(f"in {etudid} in group {group.id}")
change_etud_group_in_partition(etudid, group)
- log("%s in group %s" % (etudid, group.id))
+ log(f"{etudid} in group {group.id}")
return flask.redirect(dest_url)
@@ -1475,8 +1478,6 @@ def _get_prev_moy(etudid, formsemestre_id):
"""Donne la derniere moyenne generale calculee pour cette étudiant,
ou 0 si on n'en trouve pas (nouvel inscrit,...).
"""
- from app.scodoc import sco_cursus_dut
-
info = sco_etud.get_etud_info(etudid=etudid, filled=True)
if not info:
raise ScoValueError("etudiant invalide: etudid=%s" % etudid)
diff --git a/app/scodoc/sco_permissions_check.py b/app/scodoc/sco_permissions_check.py
index 224881bf8..dcc19f455 100644
--- a/app/scodoc/sco_permissions_check.py
+++ b/app/scodoc/sco_permissions_check.py
@@ -142,7 +142,9 @@ def check_access_diretud(formsemestre_id, required_permission=Permission.ScoImpl
def can_change_groups(formsemestre_id: int) -> bool:
- "Vrai si l'utilisateur peut changer les groupes dans ce semestre"
+ """Vrai si l'utilisateur peut changer les groupes dans ce semestre
+ Obsolete: utiliser FormSemestre.can_change_groups
+ """
formsemestre: FormSemestre = FormSemestre.query.get_or_404(formsemestre_id)
if not formsemestre.etat:
return False # semestre verrouillé
From dba48f32eb0970d7110fc6ddb75137a1f0e5c7cd Mon Sep 17 00:00:00 2001
From: Emmanuel Viennet
Date: Sun, 9 Jul 2023 21:57:50 +0200
Subject: [PATCH 13/13] add 404
---
app/scodoc/sco_groups.py | 2 +-
1 file changed, 1 insertion(+), 1 deletion(-)
diff --git a/app/scodoc/sco_groups.py b/app/scodoc/sco_groups.py
index 689dab347..ab3e014d5 100644
--- a/app/scodoc/sco_groups.py
+++ b/app/scodoc/sco_groups.py
@@ -745,7 +745,7 @@ def setGroups(
except ValueError:
log(f"setGroups: ignoring invalid group_id={group_id}")
continue
- group: GroupDescr = GroupDescr.query.get(group_id)
+ group: GroupDescr = GroupDescr.query.get_or_404(group_id)
# Anciens membres du groupe:
old_members_set = {etud.id for etud in group.etuds}
# Place dans ce groupe les etudiants indiqués: