diff --git a/app/models/groups.py b/app/models/groups.py
index 1d24b60c08..27b763d112 100644
--- a/app/models/groups.py
+++ b/app/models/groups.py
@@ -23,7 +23,7 @@ class Partition(db.Model):
)
# "TD", "TP", ... (NULL for 'all')
partition_name = db.Column(db.String(SHORT_STR_LEN))
- # numero = ordre de presentation)
+ # Numero = ordre de presentation)
numero = db.Column(db.Integer)
# Calculer le rang ?
bul_show_rank = db.Column(
@@ -33,6 +33,10 @@ class Partition(db.Model):
show_in_lists = db.Column(
db.Boolean(), nullable=False, default=True, server_default="true"
)
+ # Editable ? (faux pour les groupes de parcours)
+ groups_editable = db.Column(
+ db.Boolean(), nullable=False, default=True, server_default="true"
+ )
groups = db.relationship(
"GroupDescr",
backref=db.backref("partition", lazy=True),
diff --git a/app/scodoc/sco_formsemestre_inscriptions.py b/app/scodoc/sco_formsemestre_inscriptions.py
index b3fe985327..394af3be57 100644
--- a/app/scodoc/sco_formsemestre_inscriptions.py
+++ b/app/scodoc/sco_formsemestre_inscriptions.py
@@ -35,6 +35,7 @@ from flask import url_for, g, request
from app.comp import res_sem
from app.comp.res_compat import NotesTableCompat
from app.models import FormSemestre
+from app.models.groups import GroupDescr, Partition
import app.scodoc.sco_utils as scu
from app import log
from app.scodoc.scolog import logdb
@@ -263,8 +264,7 @@ def do_formsemestre_inscription_with_modules(
args["etat"] = etat
do_formsemestre_inscription_create(args, method=method)
log(
- "do_formsemestre_inscription_with_modules: etudid=%s formsemestre_id=%s"
- % (etudid, formsemestre_id)
+ f"do_formsemestre_inscription_with_modules: etudid={etudid} formsemestre_id={formsemestre_id}"
)
# inscriptions aux groupes
# 1- inscrit au groupe 'tous'
@@ -275,8 +275,14 @@ def do_formsemestre_inscription_with_modules(
# 2- inscrit aux groupes
for group_id in group_ids:
if group_id and not group_id in gdone:
- sco_groups.set_group(etudid, group_id)
- gdone[group_id] = 1
+ group = GroupDescr.query.get_or_404(group_id)
+ if group.partition.groups_editable:
+ sco_groups.set_group(etudid, group_id)
+ gdone[group_id] = 1
+ else:
+ log(
+ f"do_formsemestre_inscription_with_modules: group {group:r} belongs to non editable partition"
+ )
# inscription a tous les modules de ce semestre
modimpls = sco_moduleimpl.moduleimpl_withmodule_list(
@@ -534,11 +540,14 @@ def formsemestre_inscription_option(etudid, formsemestre_id):
ue_status = nt.get_etud_ue_status(etudid, ue_id)
if ue_status and ue_status["is_capitalized"]:
sem_origin = sco_formsemestre.get_formsemestre(ue_status["formsemestre_id"])
- ue_descr += ' (capitalisée le %s)' % (
- sem_origin["formsemestre_id"],
- etudid,
- sem_origin["titreannee"],
- ndb.DateISOtoDMY(ue_status["event_date"]),
+ ue_descr += (
+ ' (capitalisée le %s)'
+ % (
+ sem_origin["formsemestre_id"],
+ etudid,
+ sem_origin["titreannee"],
+ ndb.DateISOtoDMY(ue_status["event_date"]),
+ )
)
descr.append(
(
diff --git a/app/scodoc/sco_formsemestre_status.py b/app/scodoc/sco_formsemestre_status.py
index 10e5dbe932..5cc5c47a60 100644
--- a/app/scodoc/sco_formsemestre_status.py
+++ b/app/scodoc/sco_formsemestre_status.py
@@ -346,7 +346,7 @@ def formsemestre_status_menubar(sem):
"title": "%s" % partition["partition_name"],
"endpoint": "scolar.affect_groups",
"args": {"partition_id": partition["partition_id"]},
- "enabled": enabled,
+ "enabled": enabled and partition["groups_editable"],
}
)
menuGroupes.append(
diff --git a/app/scodoc/sco_groups.py b/app/scodoc/sco_groups.py
index 8eae60e040..50e0e70ee0 100644
--- a/app/scodoc/sco_groups.py
+++ b/app/scodoc/sco_groups.py
@@ -76,10 +76,12 @@ partitionEditor = ndb.EditableTable(
"numero",
"bul_show_rank",
"show_in_lists",
+ "editable",
),
input_formators={
"bul_show_rank": bool,
"show_in_lists": bool,
+ "editable": bool,
},
)
@@ -621,10 +623,12 @@ def comp_origin(etud, cur_sem):
return "" # parcours normal, ne le signale pas
-def set_group(etudid, group_id):
+def set_group(etudid: int, group_id: int) -> bool:
"""Inscrit l'étudiant au groupe.
Return True if ok, False si deja inscrit.
- Warning: don't check if group_id exists (the caller should check).
+ Warning:
+ - don't check if group_id exists (the caller should check).
+ - don't check if group's partition is editable
"""
cnx = ndb.GetDBConnexion()
cursor = cnx.cursor(cursor_factory=ndb.ScoDocCursor)
@@ -698,14 +702,28 @@ def setGroups(
groupsToCreate="", # name and members of new groups
groupsToDelete="", # groups to delete
):
- """Affect groups (Ajax request)
+ """Affect groups (Ajax request): renvoie du XML
groupsLists: lignes de la forme "group_id;etudid;...\n"
groupsToCreate: lignes "group_name;etudid;...\n"
groupsToDelete: group_id;group_id;...
+
+ Ne peux pas modifier les groupes des partitions non éditables.
"""
from app.scodoc import sco_formsemestre
+ def xml_error(msg, code=404):
+ data = (
+ f'