From 7e6d1ebba0cc2f2745da5bdd89e1224e51b85baf Mon Sep 17 00:00:00 2001 From: Emmanuel Viennet Date: Mon, 27 Feb 2023 15:39:29 +0100 Subject: [PATCH] =?UTF-8?q?G=C3=A9n=C3=A8re=20code=20par=20d=C3=A9faut=20p?= =?UTF-8?q?our=20les=20nouvelles=20UEs?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- app/scodoc/sco_edit_ue.py | 11 +++++++++++ 1 file changed, 11 insertions(+) diff --git a/app/scodoc/sco_edit_ue.py b/app/scodoc/sco_edit_ue.py index a5710c825..623753ddb 100644 --- a/app/scodoc/sco_edit_ue.py +++ b/app/scodoc/sco_edit_ue.py @@ -28,6 +28,8 @@ """Ajout/Modification/Suppression UE """ +import re + import flask from flask import flash, render_template, url_for from flask import g, request @@ -267,10 +269,19 @@ def ue_edit(ue_id=None, create=False, formation_id=None, default_semestre_idx=No else: ue = None title = "Création d'une UE" + + exp = re.compile(r"UCOD(\d+)$") + matches = {exp.match(u.ue_code) for u in UniteEns.query if exp.match(u.ue_code)} + max_code = ( + max(int(match.group(1)) for match in matches if match) if matches else 0 + ) + proposed_code = f"UCOD{max_code+1}" + initvalues = { "semestre_idx": default_semestre_idx, "color": ue_guess_color_default(formation_id, default_semestre_idx), "coef_rcue": 1.0, + "ue_code": proposed_code, } submitlabel = "Créer cette UE" can_change_semestre_id = True