forked from ScoDoc/ScoDoc
Merge branch 'iziram-master'
This commit is contained in:
commit
4272fd0444
@ -263,6 +263,15 @@ def get_group_members(group_id, etat=None):
|
|||||||
|
|
||||||
return r
|
return r
|
||||||
|
|
||||||
|
def check_group_name(group_name, partition, raiser=False):
|
||||||
|
"""If groupe name exists in partition : if raiser -> Raise ScoValueError else-> return true"""
|
||||||
|
exists = group_name in [g["group_name"] for g in get_partition_groups(partition)]
|
||||||
|
if exists:
|
||||||
|
if raiser:
|
||||||
|
raise ScoValueError("Le nom de groupe existe déjà dans la partition")
|
||||||
|
else :
|
||||||
|
return True
|
||||||
|
return False;
|
||||||
|
|
||||||
# obsolete: sco_groups_view.DisplayedGroupsInfos
|
# obsolete: sco_groups_view.DisplayedGroupsInfos
|
||||||
# def get_groups_members(group_ids, etat=None):
|
# def get_groups_members(group_ids, etat=None):
|
||||||
@ -798,7 +807,7 @@ def create_group(partition_id, group_name="", default=False) -> int:
|
|||||||
if not group_name and not default:
|
if not group_name and not default:
|
||||||
raise ValueError("invalid group name: ()")
|
raise ValueError("invalid group name: ()")
|
||||||
# checkGroupName(group_name)
|
# checkGroupName(group_name)
|
||||||
if group_name in [g["group_name"] for g in get_partition_groups(partition)]:
|
if check_group_name(group_name, partition):
|
||||||
raise ValueError(
|
raise ValueError(
|
||||||
"group_name %s already exists in partition" % group_name
|
"group_name %s already exists in partition" % group_name
|
||||||
) # XXX FIX: incorrect error handling (in AJAX)
|
) # XXX FIX: incorrect error handling (in AJAX)
|
||||||
@ -1246,7 +1255,7 @@ def group_set_name(group_id, group_name, redirect=True):
|
|||||||
redirect = int(redirect)
|
redirect = int(redirect)
|
||||||
cnx = ndb.GetDBConnexion()
|
cnx = ndb.GetDBConnexion()
|
||||||
groupEditor.edit(cnx, {"group_id": group_id, "group_name": group_name})
|
groupEditor.edit(cnx, {"group_id": group_id, "group_name": group_name})
|
||||||
|
check_group_name(group_name, get_partition(group["partition_id"]), True)
|
||||||
# redirect to partition edit page:
|
# redirect to partition edit page:
|
||||||
if redirect:
|
if redirect:
|
||||||
return flask.redirect(
|
return flask.redirect(
|
||||||
|
Loading…
Reference in New Issue
Block a user