1
0
mirror of https://gitlab.com/animath/si/plateforme.git synced 2024-12-24 03:02:23 +00:00

Validate note bounds and that they are integers

Signed-off-by: Emmy D'Anello <emmy.danello@animath.fr>
This commit is contained in:
Emmy D'Anello 2024-03-30 17:07:53 +01:00
parent 234b84ef60
commit 2019c5c434
Signed by: ynerant
GPG Key ID: 3A75C55819C8CF85

View File

@ -902,6 +902,28 @@ class Pool(models.Model):
}
})
# Add range conditions
for i in range(pool_size):
for j in range(passage_width):
column = getcol(min_column + i * passage_width + j)
min_note = 0 if j < 6 else -4
max_note = 20 if j < 2 else 10 if j < 6 else 4
format_requests.append({
"setDataValidation": {
"range": a1_range_to_grid_range(f"{column}{min_row - 1}:{column}{max_row}", worksheet.id),
"rule": {
"condition": {
"type": "CUSTOM_FORMULA",
"values": [{"userEnteredValue": f'=ET(REGEXMATCH(TO_TEXT({column}4); "^-?[0-9]+$"); '
f'{column}4>={min_note}; {column}4<={max_note})'},],
},
"inputMessage": f"La saisie doit être un entier valide "
f"compris entre {min_note} et {max_note}.",
"strict": True,
},
}
})
# Remove old protected ranges
for protected_range in spreadsheet.list_protected_ranges(worksheet.id):
format_requests.append({