Skip to content
Snippets Groups Projects
Commit 4d7355a1 authored by Alice Landou's avatar Alice Landou
Browse files

Resolution ticket #628

parent e415a525
Branches
No related tags found
No related merge requests found
......@@ -311,6 +311,13 @@ def group_create(partition_id: int): # partition-group-create
args["group_name"] = args["group_name"].strip()
if not GroupDescr.check_name(partition, args["group_name"]):
return json_error(API_CLIENT_ERROR, "invalid group_name")
# le numero est optionnel
numero = args.get("numero")
if numero is None:
numeros = [gr.numero or 0 for gr in partition.groups]
numero = (max(numeros) + 1) if numeros else 0
args["numero"] = numero
args["partition_id"] = partition_id
try:
group = GroupDescr(**args)
......@@ -595,6 +602,8 @@ def partition_edit(partition_id: int):
data = request.get_json(force=True) # may raise 400 Bad Request
modified = False
partition_name = data.get("partition_name")
partition_name = partition_name.replace(":", "").replace(";", "")
#
if partition_name is not None and partition_name != partition.partition_name:
if partition.is_parcours():
......
......@@ -197,6 +197,7 @@ class Partition(ScoDocModel):
new_numero = max(numeros) + 1
else:
new_numero = 0
group_name = group_name.replace(";", "").replace(":", "")
group = GroupDescr(partition=self, group_name=group_name, numero=new_numero)
db.session.add(group)
db.session.commit()
......
......@@ -729,10 +729,6 @@ def scolars_import_admission(datafile, formsemestre_id=None, type_admission=None
)
else:
log("scolars_import_admission: partition non editable")
diag.append(
f"Attention: partition {group.partition} non editable (ignorée)"
)
#
diag.append(f"import de {etud['nomprenom']}")
n_import += 1
......
......@@ -211,7 +211,7 @@ span.calendarEdit {
<!-- Partition -->
<h3 data-idpartition="${partition.id}">
<span class="editing move">||</span>
<span>${partition.partition_name}</span>
<span class="partGrpName" oninput="trimPartGrpName(this.innerText)" >${partition.partition_name}</span>
<span class="editing modif">✏️</span>
<span class="editing suppr">❌</span>
......@@ -255,6 +255,21 @@ span.calendarEdit {
return div;
}
function trimPartGrpName(){
const field = document.querySelector(".partGrpName[contenteditable=true]");
let sanitized = field.innerText.replace(/[:;]/g, '');
field.innerText = sanitized ;
let selection = window.getSelection();
let range = document.createRange();
range.setStart(field.childNodes[0], sanitized.length);
range.collapse(true);
selection.removeAllRanges();
selection.addRange(range);
field.focus();
}
function templateFiltres_groupe(groupe) {
let div = document.createElement("button");
div.classList.add("dt-button");
......@@ -263,7 +278,7 @@ span.calendarEdit {
let title_EDT = `Identifiant EDT: ${groupe.edt_id || groupe.group_name}`;
div.innerHTML = `
<span class="editing move">||</span>
<span>${groupe.group_name}</span>
<span class="partGrpName" oninput="trimPartGrpName(this.innerText)" >${groupe.group_name}</span>
<span class="editing rename">✏️</span>
<span class="editing calendarEdit" title="${title_EDT}">📅</span>
<span class="editing suppr">❌</span>`;
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment