Fix: partition_rename error message

This commit is contained in:
Emmanuel Viennet 2021-10-24 18:28:01 +02:00
parent ad0cd6236c
commit 66d443944a

View File

@ -89,8 +89,8 @@ def get_group(group_id):
"""Returns group object, with partition""" """Returns group object, with partition"""
r = ndb.SimpleDictFetch( r = ndb.SimpleDictFetch(
"""SELECT gd.id AS group_id, gd.*, p.id AS partition_id, p.* """SELECT gd.id AS group_id, gd.*, p.id AS partition_id, p.*
FROM group_descr gd, partition p FROM group_descr gd, partition p
WHERE gd.id=%(group_id)s WHERE gd.id=%(group_id)s
AND p.id = gd.partition_id AND p.id = gd.partition_id
""", """,
{"group_id": group_id}, {"group_id": group_id},
@ -112,8 +112,8 @@ def group_delete(group, force=False):
def get_partition(partition_id): def get_partition(partition_id):
r = ndb.SimpleDictFetch( r = ndb.SimpleDictFetch(
"""SELECT p.id AS partition_id, p.* """SELECT p.id AS partition_id, p.*
FROM partition p FROM partition p
WHERE p.id = %(partition_id)s WHERE p.id = %(partition_id)s
""", """,
{"partition_id": partition_id}, {"partition_id": partition_id},
@ -126,7 +126,7 @@ def get_partition(partition_id):
def get_partitions_list(formsemestre_id, with_default=True): def get_partitions_list(formsemestre_id, with_default=True):
"""Liste des partitions pour ce semestre (list of dicts)""" """Liste des partitions pour ce semestre (list of dicts)"""
partitions = ndb.SimpleDictFetch( partitions = ndb.SimpleDictFetch(
"""SELECT p.id AS partition_id, p.* """SELECT p.id AS partition_id, p.*
FROM partition p FROM partition p
WHERE formsemestre_id=%(formsemestre_id)s WHERE formsemestre_id=%(formsemestre_id)s
ORDER BY numero""", ORDER BY numero""",
@ -143,7 +143,7 @@ def get_default_partition(formsemestre_id):
"""Get partition for 'all' students (this one always exists, with NULL name)""" """Get partition for 'all' students (this one always exists, with NULL name)"""
r = ndb.SimpleDictFetch( r = ndb.SimpleDictFetch(
"""SELECT p.id AS partition_id, p.* FROM partition p """SELECT p.id AS partition_id, p.* FROM partition p
WHERE formsemestre_id=%(formsemestre_id)s WHERE formsemestre_id=%(formsemestre_id)s
AND partition_name is NULL AND partition_name is NULL
""", """,
{"formsemestre_id": formsemestre_id}, {"formsemestre_id": formsemestre_id},
@ -170,10 +170,10 @@ def get_partition_groups(partition):
"""List of groups in this partition (list of dicts). """List of groups in this partition (list of dicts).
Some groups may be empty.""" Some groups may be empty."""
return ndb.SimpleDictFetch( return ndb.SimpleDictFetch(
"""SELECT gd.id AS group_id, p.id AS partition_id, gd.*, p.* """SELECT gd.id AS group_id, p.id AS partition_id, gd.*, p.*
FROM group_descr gd, partition p FROM group_descr gd, partition p
WHERE gd.partition_id=%(partition_id)s WHERE gd.partition_id=%(partition_id)s
AND gd.partition_id=p.id AND gd.partition_id=p.id
ORDER BY group_name ORDER BY group_name
""", """,
partition, partition,
@ -184,9 +184,9 @@ def get_default_group(formsemestre_id, fix_if_missing=False):
"""Returns group_id for default ('tous') group""" """Returns group_id for default ('tous') group"""
r = ndb.SimpleDictFetch( r = ndb.SimpleDictFetch(
"""SELECT gd.id AS group_id """SELECT gd.id AS group_id
FROM group_descr gd, partition p FROM group_descr gd, partition p
WHERE p.formsemestre_id=%(formsemestre_id)s WHERE p.formsemestre_id=%(formsemestre_id)s
AND p.partition_name is NULL AND p.partition_name is NULL
AND p.id = gd.partition_id AND p.id = gd.partition_id
""", """,
{"formsemestre_id": formsemestre_id}, {"formsemestre_id": formsemestre_id},
@ -218,8 +218,8 @@ def get_sem_groups(formsemestre_id):
"""Returns groups for this sem (in all partitions).""" """Returns groups for this sem (in all partitions)."""
return ndb.SimpleDictFetch( return ndb.SimpleDictFetch(
"""SELECT gd.id AS group_id, p.id AS partition_id, gd.*, p.* """SELECT gd.id AS group_id, p.id AS partition_id, gd.*, p.*
FROM group_descr gd, partition p FROM group_descr gd, partition p
WHERE p.formsemestre_id=%(formsemestre_id)s WHERE p.formsemestre_id=%(formsemestre_id)s
AND p.id = gd.partition_id AND p.id = gd.partition_id
""", """,
{"formsemestre_id": formsemestre_id}, {"formsemestre_id": formsemestre_id},
@ -340,7 +340,7 @@ def get_etud_groups(etudid, sem, exclude_default=False):
"""Infos sur groupes de l'etudiant dans ce semestre """Infos sur groupes de l'etudiant dans ce semestre
[ group + partition_name ] [ group + partition_name ]
""" """
req = """SELECT p.id AS partition_id, p.*, g.id AS group_id, g.* req = """SELECT p.id AS partition_id, p.*, g.id AS group_id, g.*
FROM group_descr g, partition p, group_membership gm FROM group_descr g, partition p, group_membership gm
WHERE gm.etudid=%(etudid)s WHERE gm.etudid=%(etudid)s
and gm.group_id = g.id and gm.group_id = g.id
@ -377,10 +377,10 @@ def formsemestre_get_etud_groupnames(formsemestre_id, attr="group_name"):
{ etudid : { partition_id : group_name }} (attr=group_name or group_id) { etudid : { partition_id : group_name }} (attr=group_name or group_id)
""" """
infos = ndb.SimpleDictFetch( infos = ndb.SimpleDictFetch(
"""SELECT i.id AS etudid, p.id AS partition_id, """SELECT i.id AS etudid, p.id AS partition_id,
gd.group_name, gd.id AS group_id gd.group_name, gd.id AS group_id
FROM notes_formsemestre_inscription i, partition p, FROM notes_formsemestre_inscription i, partition p,
group_descr gd, group_membership gm group_descr gd, group_membership gm
WHERE i.formsemestre_id=%(formsemestre_id)s WHERE i.formsemestre_id=%(formsemestre_id)s
and i.formsemestre_id = p.formsemestre_id and i.formsemestre_id = p.formsemestre_id
and p.id = gd.partition_id and p.id = gd.partition_id
@ -413,7 +413,7 @@ def etud_add_group_infos(etud, sem, sep=" "):
FROM group_descr g, partition p, group_membership gm WHERE gm.etudid=%(etudid)s FROM group_descr g, partition p, group_membership gm WHERE gm.etudid=%(etudid)s
and gm.group_id = g.id and gm.group_id = g.id
and g.partition_id = p.id and g.partition_id = p.id
and p.formsemestre_id = %(formsemestre_id)s and p.formsemestre_id = %(formsemestre_id)s
ORDER BY p.numero ORDER BY p.numero
""", """,
{"etudid": etud["etudid"], "formsemestre_id": sem["formsemestre_id"]}, {"etudid": etud["etudid"], "formsemestre_id": sem["formsemestre_id"]},
@ -1141,13 +1141,13 @@ def partition_set_name(partition_id, partition_name, redirect=1):
# check unicity # check unicity
r = ndb.SimpleDictFetch( r = ndb.SimpleDictFetch(
"""SELECT p.* FROM partition p """SELECT p.* FROM partition p
WHERE p.partition_name = %(partition_name)s WHERE p.partition_name = %(partition_name)s
AND formsemestre_id = %(formsemestre_id)s AND formsemestre_id = %(formsemestre_id)s
""", """,
{"partition_name": partition_name, "formsemestre_id": formsemestre_id}, {"partition_name": partition_name, "formsemestre_id": formsemestre_id},
) )
if len(r) > 1 or (len(r) == 1 and r[0]["partition_id"] != partition_id): if len(r) > 1 or (len(r) == 1 and r[0]["id"] != partition_id):
raise ScoValueError( raise ScoValueError(
"Partition %s déjà existante dans ce semestre !" % partition_name "Partition %s déjà existante dans ce semestre !" % partition_name
) )
@ -1494,9 +1494,9 @@ def listgroups(group_ids):
groups = [] groups = []
for group_id in group_ids: for group_id in group_ids:
cursor.execute( cursor.execute(
"""SELECT gd.id AS group_id, gd.*, p.id AS partition_id, p.* """SELECT gd.id AS group_id, gd.*, p.id AS partition_id, p.*
FROM group_descr gd, partition p FROM group_descr gd, partition p
WHERE p.id = gd.partition_id WHERE p.id = gd.partition_id
AND gd.id = %(group_id)s AND gd.id = %(group_id)s
""", """,
{"group_id": group_id}, {"group_id": group_id},