Don't delete extra jury lines on Google Sheets

Signed-off-by: Emmy D'Anello <emmy.danello@animath.fr>
This commit is contained in:
Emmy D'Anello 2024-03-31 15:34:21 +02:00
parent 779aec5e55
commit c4ec6a6f29
Signed by: ynerant
GPG Key ID: 3A75C55819C8CF85
1 changed files with 2 additions and 6 deletions

View File

@ -1269,13 +1269,9 @@ class Pool(models.Model):
max_row = average_cell.row - 1
juries_visible = worksheet.get(f"A{min_row}:B{max_row}")
juries_visible = [t for t in juries_visible if t and len(t) == 2]
rows_to_delete = []
for i, (_jury_name, jury_id) in enumerate(juries_visible):
for i, (jury_name, jury_id) in enumerate(juries_visible):
if not jury_id.isnumeric() or int(jury_id) not in self.juries.values_list("id", flat=True):
rows_to_delete.append(min_row + i)
for row_to_delete in rows_to_delete:
worksheet.delete_rows(row_to_delete)
max_row -= len(rows_to_delete)
print(f"Warning: {jury_name} ({jury_id}) appears on the sheet but is not part of the jury.")
for jury in self.juries.all():
if str(jury.id) not in list(map(lambda x: x[1], juries_visible)):