From a155655e004c5ba25dafe18ce786faf8bffba8ae Mon Sep 17 00:00:00 2001 From: Emmanuel Viennet Date: Sat, 3 Sep 2022 08:42:41 +0200 Subject: [PATCH] Fix: creattion groupe (numero) --- app/scodoc/sco_groups.py | 8 +++++--- sco_version.py | 2 +- 2 files changed, 6 insertions(+), 4 deletions(-) diff --git a/app/scodoc/sco_groups.py b/app/scodoc/sco_groups.py index c68e4342a..ca6246f4c 100644 --- a/app/scodoc/sco_groups.py +++ b/app/scodoc/sco_groups.py @@ -844,9 +844,11 @@ def create_group(partition_id, group_name="", default=False) -> GroupDescr: if not GroupDescr.check_name(partition, group_name): raise ScoValueError(f"Le groupe {group_name} existe déjà dans cette partition") - new_numero = ( - max([g.numero if g.numero is not None else 0 for g in partition.groups]) + 1 - ) + numeros = [g.numero if g.numero is not None else 0 for g in partition.groups] + if len(numeros) > 0: + new_numero = max(numeros) + 1 + else: + new_numero = 0 group = GroupDescr(partition=partition, group_name=group_name, numero=new_numero) db.session.add(group) db.session.commit() diff --git a/sco_version.py b/sco_version.py index 60ae7efa1..e793d4d3b 100644 --- a/sco_version.py +++ b/sco_version.py @@ -1,7 +1,7 @@ # -*- mode: python -*- # -*- coding: utf-8 -*- -SCOVERSION = "9.3.30" +SCOVERSION = "9.3.31" SCONAME = "ScoDoc"