diff --git a/app/scodoc/sco_formsemestre_status.py b/app/scodoc/sco_formsemestre_status.py index fbf16c3de..71823e10f 100644 --- a/app/scodoc/sco_formsemestre_status.py +++ b/app/scodoc/sco_formsemestre_status.py @@ -325,7 +325,7 @@ def formsemestre_status_menubar(sem): }, { "title": "Créer/modifier les partitions...", - "endpoint": "scolar.editPartitionForm", + "endpoint": "scolar.edit_partition_form", "args": {"formsemestre_id": formsemestre_id}, "enabled": sco_groups.sco_permissions_check.can_change_groups( formsemestre_id @@ -854,7 +854,7 @@ def _make_listes_sem(sem, with_absences=True): H.append( f"""

@@ -1000,28 +1001,49 @@ def editPartitionForm(formsemestre_id=None): # H.append("") H.append("") - H.append('
') H.append( - '' % formsemestre_id + f""" + + """ ) - H.append('') - H.append("
") H.append( """
-

Les partitions sont des découpages de l'ensemble des étudiants. - Par exemple, les "groupes de TD" sont une partition. - On peut créer autant de partitions que nécessaire. +

Les partitions sont des découpages de l'ensemble des étudiants. + Par exemple, les "groupes de TD" sont une partition. + On peut créer autant de partitions que nécessaire.

""" @@ -1077,7 +1099,7 @@ def partition_delete(partition_id, force=False, redirect=1, dialog_confirmed=Fal """ % (partition["partition_name"], grnames), dest_url="", - cancel_url="editPartitionForm?formsemestre_id=%s" % formsemestre_id, + cancel_url="edit_partition_form?formsemestre_id=%s" % formsemestre_id, parameters={"redirect": redirect, "partition_id": partition_id}, ) @@ -1091,7 +1113,7 @@ def partition_delete(partition_id, force=False, redirect=1, dialog_confirmed=Fal # redirect to partition edit page: if redirect: return flask.redirect( - "editPartitionForm?formsemestre_id=" + str(formsemestre_id) + "edit_partition_form?formsemestre_id=" + str(formsemestre_id) ) @@ -1148,7 +1170,7 @@ def partition_move(partition_id, after=0, redirect=1): # redirect to partition edit page: if redirect: return flask.redirect( - "editPartitionForm?formsemestre_id=" + str(formsemestre_id) + "edit_partition_form?formsemestre_id=" + str(formsemestre_id) ) @@ -1188,7 +1210,7 @@ def partition_rename(partition_id): ) elif tf[0] == -1: return flask.redirect( - "editPartitionForm?formsemestre_id=" + str(formsemestre_id) + "edit_partition_form?formsemestre_id=" + str(formsemestre_id) ) else: # form submission @@ -1229,7 +1251,7 @@ def partition_set_name(partition_id, partition_name, redirect=1): # redirect to partition edit page: if redirect: return flask.redirect( - "editPartitionForm?formsemestre_id=" + str(formsemestre_id) + "edit_partition_form?formsemestre_id=" + str(formsemestre_id) ) diff --git a/app/static/js/editPartitionForm.js b/app/static/js/edit_partition_form.js similarity index 100% rename from app/static/js/editPartitionForm.js rename to app/static/js/edit_partition_form.js diff --git a/app/views/scolar.py b/app/views/scolar.py index e0472af1c..4bc3f27f5 100644 --- a/app/views/scolar.py +++ b/app/views/scolar.py @@ -54,6 +54,7 @@ from app.decorators import ( from app.models.etudiants import Identite from app.models.etudiants import make_etud_args from app.models.events import ScolarNews +from app.models.formsemestre import FormSemestre from app.views import scolar_bp as bp from app.views import ScoData @@ -860,8 +861,8 @@ sco_publish( ) sco_publish( - "/editPartitionForm", - sco_groups.editPartitionForm, + "/edit_partition_form", + sco_groups.edit_partition_form, Permission.ScoView, methods=["GET", "POST"], ) @@ -904,21 +905,37 @@ sco_publish( sco_publish( "/partition_create", sco_groups.partition_create, - Permission.ScoView, + Permission.ScoView, # controle d'access ad-hoc methods=["GET", "POST"], ) -# @bp.route("/partition_create", methods=["GET", "POST"]) -# @scodoc -# @permission_required(Permission.ScoView) -# @scodoc7func -# def partition_create( -# -# formsemestre_id, -# partition_name="", -# default=False, -# numero=None, -# redirect=1): -# return sco_groups.partition_create( formsemestre_id, + + +@bp.route("/create_partition_parcours", methods=["GET", "POST"]) +@scodoc +@permission_required(Permission.ScoView) +@scodoc7func +def create_partition_parcours(formsemestre_id): + """Création d'une partitions nommée "Parcours" avec un groupe par parcours.""" + formsemestre = FormSemestre.query.get_or_404(formsemestre_id) + if "Parcours" in (p.partition_name for p in formsemestre.partitions): + flash("""Partition "Parcours" déjà existante""") + else: + partition_id = sco_groups.partition_create( + formsemestre_id, partition_name="Parcours", redirect=False + ) + n = 0 + for parcour in formsemestre.parcours: + if parcour.code: + _ = sco_groups.create_group(partition_id, group_name=parcour.code) + n += 1 + flash(f"Partition Parcours créée avec {n} groupes.") + return flask.redirect( + url_for( + "scolar.edit_partition_form", + scodoc_dept=g.scodoc_dept, + formsemestre_id=formsemestre_id, + ) + ) sco_publish("/etud_info_html", sco_page_etud.etud_info_html, Permission.ScoView)