From 3ef1f155b7170a5d1a1e569c4fd0921091b3bc80 Mon Sep 17 00:00:00 2001 From: Emmanuel Viennet Date: Sun, 30 Jan 2022 11:56:55 +0100 Subject: [PATCH] =?UTF-8?q?BUT:=20cr=C3=A9ation=20module:=20choix=20semest?= =?UTF-8?q?re=20et=20non=20plus=20UE?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- app/scodoc/sco_edit_apc.py | 9 ++++++++ app/scodoc/sco_edit_module.py | 41 ++++----------------------------- app/templates/pn/form_mods.html | 4 ++-- 3 files changed, 16 insertions(+), 38 deletions(-) diff --git a/app/scodoc/sco_edit_apc.py b/app/scodoc/sco_edit_apc.py index a9eff6de..c1c75319 100644 --- a/app/scodoc/sco_edit_apc.py +++ b/app/scodoc/sco_edit_apc.py @@ -33,6 +33,7 @@ from flask_login import current_user from app import db from app.models import Formation, UniteEns, Matiere, Module, FormSemestre, ModuleImpl from app.models.notes import ScolarFormSemestreValidation +from app.scodoc.sco_codes_parcours import UE_SPORT import app.scodoc.sco_utils as scu from app.scodoc import sco_groups from app.scodoc.sco_utils import ModuleType @@ -99,12 +100,19 @@ def html_edit_formation_apc( ressources_in_sem = ressources.filter_by(semestre_id=semestre_idx) saes_in_sem = saes.filter_by(semestre_id=semestre_idx) other_modules_in_sem = other_modules.filter_by(semestre_id=semestre_idx) + matiere_parent = Matiere.query.filter( + Matiere.ue_id == UniteEns.id, + UniteEns.formation_id == formation.id, + UniteEns.semestre_idx == semestre_idx, + UniteEns.type != UE_SPORT, + ).first() H += [ render_template( "pn/form_mods.html", formation=formation, titre=f"Ressources du S{semestre_idx}", create_element_msg="créer une nouvelle ressource", + matiere_parent=matiere_parent, modules=ressources_in_sem, module_type=ModuleType.RESSOURCE, editable=editable, @@ -117,6 +125,7 @@ def html_edit_formation_apc( formation=formation, titre=f"Situations d'Apprentissage et d'Évaluation (SAÉs) S{semestre_idx}", create_element_msg="créer une nouvelle SAÉ", + matiere_parent=matiere_parent, modules=saes_in_sem, module_type=ModuleType.SAE, editable=editable, diff --git a/app/scodoc/sco_edit_module.py b/app/scodoc/sco_edit_module.py index 1c42d53f..ae143cbc 100644 --- a/app/scodoc/sco_edit_module.py +++ b/app/scodoc/sco_edit_module.py @@ -145,7 +145,7 @@ def module_create(matiere_id=None, module_type=None, semestre_id=None): ] if is_apc: H += [ - f"""

Création {object_name} dans la formation {ue.formation.acronyme}

""" + f"""

Création {object_name} dans la formation {ue.formation.acronyme}, Semestre {ue.semestre_idx}, {ue.acronyme}

""" ] else: H += [ @@ -191,35 +191,7 @@ def module_create(matiere_id=None, module_type=None, semestre_id=None): ), ] semestres_indices = list(range(1, parcours.NB_SEM + 1)) - if is_apc: # BUT: choix de l'UE de rattachement (qui donnera le semestre) - descr += [ - ( - "ue_id", - { - "input_type": "menu", - "type": "int", - "title": "UE de rattachement", - "explanation": "utilisée pour la présentation dans certains documents", - "labels": [f"{u.acronyme} {u.titre}" for u in ues], - "allowed_values": [u.id for u in ues], - }, - ), - ] - else: - # Formations classiques: choix du semestre - descr += [ - ( - "semestre_id", - { - "input_type": "menu", - "type": "int", - "title": parcours.SESSION_NAME.capitalize(), - "explanation": "%s du module" % parcours.SESSION_NAME, - "labels": [str(x) for x in semestres_indices], - "allowed_values": semestres_indices, - }, - ), - ] + descr += [ ( "module_type", @@ -318,12 +290,7 @@ def module_create(matiere_id=None, module_type=None, semestre_id=None): if tf[0] == 0: return "\n".join(H) + tf[1] + html_sco_header.sco_footer() else: - if is_apc: - # BUT: l'UE indique le semestre - selected_ue = UniteEns.query.get(tf[2]["ue_id"]) - if selected_ue is None: - raise ValueError("UE invalide") - tf[2]["semestre_id"] = selected_ue.semestre_idx + tf[2]["semestre_id"] = ue.semestre_idx _ = do_module_create(tf[2]) @@ -719,6 +686,8 @@ def module_edit(module_id=None): """ + else: + sem_descr = "" # if tf[0] == 0: return "\n".join(H) + tf[1] + sem_descr + html_sco_header.sco_footer() diff --git a/app/templates/pn/form_mods.html b/app/templates/pn/form_mods.html index cba28347..e5ca79e5 100644 --- a/app/templates/pn/form_mods.html +++ b/app/templates/pn/form_mods.html @@ -71,12 +71,12 @@ {% endfor %} - {% if editable and formation.ues.count() and formation.ues[0].matieres.count() %} + {% if editable and matiere_parent %}
  • {{create_element_msg}}