1
0
mirror of https://gitlab.com/animath/si/plateforme.git synced 2025-06-22 15:18:24 +02:00

Don't display ranking in notation ODS when there are 5 teams

Signed-off-by: Emmy D'Anello <emmy.danello@animath.fr>
This commit is contained in:
Emmy D'Anello
2024-04-19 18:30:59 +02:00
parent 0845d0bfb6
commit 86e978faf2
3 changed files with 68 additions and 56 deletions

View File

@ -276,7 +276,6 @@ class UploadNotesForm(forms.Form):
def process(self, df: pandas.DataFrame, cleaned_data: dict):
parsed_notes = {}
valid_lengths = [2 + 6 * 3, 2 + 7 * 4, 2 + 6 * 5] # Per pool sizes
pool_size = 0
line_length = 0
for line in df.values.tolist():
@ -286,10 +285,7 @@ class UploadNotesForm(forms.Form):
line = [str(s).strip() for s in line if str(s)]
if line and line[0] == 'Problème':
pool_size = len(line) - 1
if pool_size < 3 or pool_size > 5:
self.add_error('file', _("Can't determine the pool size. Are you sure your file is correct?"))
return
line_length = valid_lengths[pool_size - 3]
line_length = 2 + 6 * pool_size
continue
if pool_size == 0 or len(line) < line_length:
@ -299,11 +295,13 @@ class UploadNotesForm(forms.Form):
if name.lower() in ["rôle", "juré⋅e", "juré?e", "moyenne", "coefficient", "sous-total", "équipe", "equipe"]:
continue
notes = line[2:line_length]
print(name, notes)
if not all(s.isnumeric() or s[0] == '-' and s[1:].isnumeric() for s in notes):
continue
notes = list(map(lambda x: int(float(x)), notes))
print(notes)
max_notes = pool_size * ([20, 20, 10, 10, 10, 10] + ([4] if pool_size == 4 else []))
max_notes = pool_size * [20, 20, 10, 10, 10, 10]
for n, max_n in zip(notes, max_notes):
if n > max_n:
self.add_error('file',
@ -317,6 +315,8 @@ class UploadNotesForm(forms.Form):
jury = jury.get()
parsed_notes[jury] = notes
print(parsed_notes)
cleaned_data['parsed_notes'] = parsed_notes
return cleaned_data