Validate note bounds and that they are integers
Signed-off-by: Emmy D'Anello <emmy.danello@animath.fr>
This commit is contained in:
parent
234b84ef60
commit
2019c5c434
|
@ -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
|
# Remove old protected ranges
|
||||||
for protected_range in spreadsheet.list_protected_ranges(worksheet.id):
|
for protected_range in spreadsheet.list_protected_ranges(worksheet.id):
|
||||||
format_requests.append({
|
format_requests.append({
|
||||||
|
|
Loading…
Reference in New Issue