👉💡 vous pourriez essayer le nouvel éditeur
""" ) 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 groupes %s de cette partition seront supprimés
""" % (partition["partition_name"], grnames), dest_url="", cancel_url="edit_partition_form?formsemestre_id=%s" % formsemestre_id, parameters={"redirect": redirect, "partition_id": partition_id}, ) log("partition_delete: partition_id=%s" % partition_id) # 1- groups for group in groups: group_delete(group["group_id"]) # 2- partition partitionEditor.delete(cnx, partition_id) formsemestre.update_inscriptions_parcours_from_groups() # redirect to partition edit page: if redirect: return flask.redirect( "edit_partition_form?formsemestre_id=" + str(formsemestre_id) ) def partition_move(partition_id, after=0, redirect=1): """Move before/after previous one (decrement/increment numero)""" partition = get_partition(partition_id) formsemestre_id = partition["formsemestre_id"] formsemestre = FormSemestre.get_formsemestre(formsemestre_id) if not formsemestre.can_change_groups(): raise AccessDenied("Vous n'avez pas le droit d'effectuer cette opération !") # redirect = int(redirect) after = int(after) # 0: deplace avant, 1 deplace apres if after not in (0, 1): raise ValueError('invalid value for "after"') others = get_partitions_list(formsemestre_id) objs = ( Partition.query.filter_by(formsemestre_id=formsemestre_id) .order_by(Partition.numero, Partition.partition_name) .all() ) if len({o.numero for o in objs}) != len(objs): # il y a des numeros identiques ! scu.objects_renumber(db, objs) if len(others) > 1: pidx = [p["partition_id"] for p in others].index(partition_id) # log("partition_move: after=%s pidx=%s" % (after, pidx)) neigh = None # partition to swap with if after == 0 and pidx > 0: neigh = others[pidx - 1] elif after == 1 and pidx < len(others) - 1: neigh = others[pidx + 1] if neigh: # # swap numero between partition and its neighbor # log("moving partition %s" % partition_id) cnx = ndb.GetDBConnexion() # Si aucun numéro n'a été affecté, le met au minimum min_numero = ( ndb.SimpleQuery( "SELECT MIN(numero) FROM partition WHERE formsemestre_id=%(formsemestre_id)s", {"formsemestre_id": formsemestre_id}, ).fetchone()[0] or 0 ) if neigh["numero"] is None: neigh["numero"] = min_numero - 1 if partition["numero"] is None: partition["numero"] = min_numero - 1 - after partition["numero"], neigh["numero"] = neigh["numero"], partition["numero"] partitionEditor.edit(cnx, partition) partitionEditor.edit(cnx, neigh) sco_cache.invalidate_formsemestre(formsemestre_id=formsemestre_id) # redirect to partition edit page: if redirect: return flask.redirect( "edit_partition_form?formsemestre_id=" + str(formsemestre_id) ) def partition_rename(partition_id): """Form to rename a partition""" partition = get_partition(partition_id) formsemestre_id = partition["formsemestre_id"] formsemestre = FormSemestre.get_formsemestre(formsemestre_id) if not formsemestre.can_change_groups(): raise AccessDenied("Vous n'avez pas le droit d'effectuer cette opération !") H = ["Groupe de %(partition_name)s | " % p) H.append(' |