From 0845d0bfb61b6507f162f13cc944d003e5651ece Mon Sep 17 00:00:00 2001 From: Emmy D'Anello Date: Thu, 18 Apr 2024 15:41:27 +0200 Subject: [PATCH] Since a notation sheet has at most 4 passages, reduce the number of columns to 26 Signed-off-by: Emmy D'Anello --- participation/models.py | 26 +++++++++++++------------- 1 file changed, 13 insertions(+), 13 deletions(-) diff --git a/participation/models.py b/participation/models.py index 389e149..6b0cc7c 100644 --- a/participation/models.py +++ b/participation/models.py @@ -528,7 +528,7 @@ class Tournament(models.Model): }) # Set borders - border_ranges = [("A1:AF", "0000"), + border_ranges = [("A1:Z", "0000"), (f"A1:G{participations.count() + 1}", "1111"), (f"A{participations.count() + 4}:D{2 * participations.count() + 4}", "1111")] sides_names = ['top', 'bottom', 'left', 'right'] @@ -551,7 +551,7 @@ class Tournament(models.Model): }) # Make titles bold - bold_ranges = [("A1:AF", False), ("A1:G1", True), + bold_ranges = [("A1:Z", False), ("A1:G1", True), (f"A{participations.count() + 4}:D{participations.count() + 4}", True)] for bold_range, bold in bold_ranges: format_requests.append({ @@ -563,7 +563,7 @@ class Tournament(models.Model): }) # Set background color for headers and footers - bg_colors = [("A1:AF", (1, 1, 1)), + bg_colors = [("A1:Z", (1, 1, 1)), ("A1:G1", (0.8, 0.8, 0.8)), (f"A2:B{participations.count() + 1}", (0.9, 0.9, 0.9)), (f"C2:C{participations.count() + 1}", (1, 1, 1)), @@ -1037,7 +1037,7 @@ class Pool(models.Model): spreadsheet = gc.open_by_key(self.tournament.notes_sheet_id) worksheets = spreadsheet.worksheets() if f"Poule {self.short_name}" not in [ws.title for ws in worksheets]: - worksheet = spreadsheet.add_worksheet(f"Poule {self.short_name}", 100, 32) + worksheet = spreadsheet.add_worksheet(f"Poule {self.short_name}", 100, 26) else: worksheet = spreadsheet.worksheet(f"Poule {self.short_name}") if any(ws.title == "Sheet1" for ws in worksheets): @@ -1145,8 +1145,8 @@ class Pool(models.Model): all_values = header + notes + footer + ranking - worksheet.batch_clear([f"A1:AF{max_row + 5 + pool_size}"]) - worksheet.update("A1:AF", all_values, raw=False) + worksheet.batch_clear([f"A1:Z{max_row + 5 + pool_size}"]) + worksheet.update("A1:Z", all_values, raw=False) format_requests = [] @@ -1172,13 +1172,13 @@ class Pool(models.Model): for i in range(pool_size + 1): merge_cells.append(f"A{max_row + 5 + i}:B{max_row + 5 + i}") - format_requests.append({"unmergeCells": {"range": a1_range_to_grid_range("A1:AF", worksheet.id)}}) + format_requests.append({"unmergeCells": {"range": a1_range_to_grid_range("A1:Z", worksheet.id)}}) for name in merge_cells: grid_range = a1_range_to_grid_range(name, worksheet.id) format_requests.append({"mergeCells": {"mergeType": MergeType.merge_all, "range": grid_range}}) # Make titles bold - bold_ranges = [("A1:AF", False), ("A1:AF3", True), + bold_ranges = [("A1:Z", False), ("A1:Z3", True), (f"A{max_row + 1}:B{max_row + 3}", True), (f"A{max_row + 5}:E{max_row + 5}", True)] for bold_range, bold in bold_ranges: format_requests.append({ @@ -1190,7 +1190,7 @@ class Pool(models.Model): }) # Set background color for headers and footers - bg_colors = [("A1:AF", (1, 1, 1)), + bg_colors = [("A1:Z", (1, 1, 1)), (f"A1:{getcol(2 + passages.count() * passage_width)}3", (0.8, 0.8, 0.8)), (f"A{min_row - 1}:B{max_row}", (0.95, 0.95, 0.95)), (f"A{max_row + 1}:B{max_row + 3}", (0.8, 0.8, 0.8)), @@ -1276,7 +1276,7 @@ class Pool(models.Model): }) # Define borders - border_ranges = [("A1:AF", "0000"), + border_ranges = [("A1:Z", "0000"), (f"A1:{getcol(2 + passages.count() * passage_width)}{max_row + 3}", "1111"), (f"A{max_row + 5}:E{max_row + pool_size + 5}", "1111"), (f"A1:B{max_row + 3}", "1113"), @@ -1351,9 +1351,9 @@ class Pool(models.Model): }) # Protect the header, the juries list, the footer and the ranking - protected_ranges = ["A1:AF4", + protected_ranges = ["A1:Z4", f"A{min_row}:B{max_row}", - f"A{max_row}:AF{max_row + 5 + pool_size}"] + f"A{max_row}:Z{max_row + 5 + pool_size}"] for protected_range in protected_ranges: format_requests.append({ "addProtectedRange": { @@ -1397,7 +1397,7 @@ class Pool(models.Model): average_cell = worksheet.find("Moyenne") min_row = 5 max_row = average_cell.row - 2 - data = worksheet.get_values(f"A{min_row}:AF{max_row}") + data = worksheet.get_values(f"A{min_row}:Z{max_row}") if not data or not data[0]: return