mirror of
				https://gitlab.com/animath/si/plateforme.git
				synced 2025-11-04 04:22:14 +01:00 
			
		
		
		
	Since a notation sheet has at most 4 passages, reduce the number of columns to 26
Signed-off-by: Emmy D'Anello <emmy.danello@animath.fr>
This commit is contained in:
		@@ -528,7 +528,7 @@ class Tournament(models.Model):
 | 
				
			|||||||
            })
 | 
					            })
 | 
				
			||||||
 | 
					
 | 
				
			||||||
        # Set borders
 | 
					        # Set borders
 | 
				
			||||||
        border_ranges = [("A1:AF", "0000"),
 | 
					        border_ranges = [("A1:Z", "0000"),
 | 
				
			||||||
                         (f"A1:G{participations.count() + 1}", "1111"),
 | 
					                         (f"A1:G{participations.count() + 1}", "1111"),
 | 
				
			||||||
                         (f"A{participations.count() + 4}:D{2 * participations.count() + 4}", "1111")]
 | 
					                         (f"A{participations.count() + 4}:D{2 * participations.count() + 4}", "1111")]
 | 
				
			||||||
        sides_names = ['top', 'bottom', 'left', 'right']
 | 
					        sides_names = ['top', 'bottom', 'left', 'right']
 | 
				
			||||||
@@ -551,7 +551,7 @@ class Tournament(models.Model):
 | 
				
			|||||||
            })
 | 
					            })
 | 
				
			||||||
 | 
					
 | 
				
			||||||
        # Make titles bold
 | 
					        # 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)]
 | 
					                       (f"A{participations.count() + 4}:D{participations.count() + 4}", True)]
 | 
				
			||||||
        for bold_range, bold in bold_ranges:
 | 
					        for bold_range, bold in bold_ranges:
 | 
				
			||||||
            format_requests.append({
 | 
					            format_requests.append({
 | 
				
			||||||
@@ -563,7 +563,7 @@ class Tournament(models.Model):
 | 
				
			|||||||
            })
 | 
					            })
 | 
				
			||||||
 | 
					
 | 
				
			||||||
        # Set background color for headers and footers
 | 
					        # 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)),
 | 
					                     ("A1:G1", (0.8, 0.8, 0.8)),
 | 
				
			||||||
                     (f"A2:B{participations.count() + 1}", (0.9, 0.9, 0.9)),
 | 
					                     (f"A2:B{participations.count() + 1}", (0.9, 0.9, 0.9)),
 | 
				
			||||||
                     (f"C2:C{participations.count() + 1}", (1, 1, 1)),
 | 
					                     (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)
 | 
					        spreadsheet = gc.open_by_key(self.tournament.notes_sheet_id)
 | 
				
			||||||
        worksheets = spreadsheet.worksheets()
 | 
					        worksheets = spreadsheet.worksheets()
 | 
				
			||||||
        if f"Poule {self.short_name}" not in [ws.title for ws in 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:
 | 
					        else:
 | 
				
			||||||
            worksheet = spreadsheet.worksheet(f"Poule {self.short_name}")
 | 
					            worksheet = spreadsheet.worksheet(f"Poule {self.short_name}")
 | 
				
			||||||
        if any(ws.title == "Sheet1" for ws in worksheets):
 | 
					        if any(ws.title == "Sheet1" for ws in worksheets):
 | 
				
			||||||
@@ -1145,8 +1145,8 @@ class Pool(models.Model):
 | 
				
			|||||||
 | 
					
 | 
				
			||||||
        all_values = header + notes + footer + ranking
 | 
					        all_values = header + notes + footer + ranking
 | 
				
			||||||
 | 
					
 | 
				
			||||||
        worksheet.batch_clear([f"A1:AF{max_row + 5 + pool_size}"])
 | 
					        worksheet.batch_clear([f"A1:Z{max_row + 5 + pool_size}"])
 | 
				
			||||||
        worksheet.update("A1:AF", all_values, raw=False)
 | 
					        worksheet.update("A1:Z", all_values, raw=False)
 | 
				
			||||||
 | 
					
 | 
				
			||||||
        format_requests = []
 | 
					        format_requests = []
 | 
				
			||||||
 | 
					
 | 
				
			||||||
@@ -1172,13 +1172,13 @@ class Pool(models.Model):
 | 
				
			|||||||
        for i in range(pool_size + 1):
 | 
					        for i in range(pool_size + 1):
 | 
				
			||||||
            merge_cells.append(f"A{max_row + 5 + i}:B{max_row + 5 + i}")
 | 
					            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:
 | 
					        for name in merge_cells:
 | 
				
			||||||
            grid_range = a1_range_to_grid_range(name, worksheet.id)
 | 
					            grid_range = a1_range_to_grid_range(name, worksheet.id)
 | 
				
			||||||
            format_requests.append({"mergeCells": {"mergeType": MergeType.merge_all, "range": grid_range}})
 | 
					            format_requests.append({"mergeCells": {"mergeType": MergeType.merge_all, "range": grid_range}})
 | 
				
			||||||
 | 
					
 | 
				
			||||||
        # Make titles bold
 | 
					        # 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)]
 | 
					                       (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:
 | 
					        for bold_range, bold in bold_ranges:
 | 
				
			||||||
            format_requests.append({
 | 
					            format_requests.append({
 | 
				
			||||||
@@ -1190,7 +1190,7 @@ class Pool(models.Model):
 | 
				
			|||||||
            })
 | 
					            })
 | 
				
			||||||
 | 
					
 | 
				
			||||||
        # Set background color for headers and footers
 | 
					        # 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"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{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)),
 | 
					                     (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
 | 
					        # 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"A1:{getcol(2 + passages.count() * passage_width)}{max_row + 3}", "1111"),
 | 
				
			||||||
                         (f"A{max_row + 5}:E{max_row + pool_size + 5}", "1111"),
 | 
					                         (f"A{max_row + 5}:E{max_row + pool_size + 5}", "1111"),
 | 
				
			||||||
                         (f"A1:B{max_row + 3}", "1113"),
 | 
					                         (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
 | 
					        # 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{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:
 | 
					        for protected_range in protected_ranges:
 | 
				
			||||||
            format_requests.append({
 | 
					            format_requests.append({
 | 
				
			||||||
                "addProtectedRange": {
 | 
					                "addProtectedRange": {
 | 
				
			||||||
@@ -1397,7 +1397,7 @@ class Pool(models.Model):
 | 
				
			|||||||
        average_cell = worksheet.find("Moyenne")
 | 
					        average_cell = worksheet.find("Moyenne")
 | 
				
			||||||
        min_row = 5
 | 
					        min_row = 5
 | 
				
			||||||
        max_row = average_cell.row - 2
 | 
					        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]:
 | 
					        if not data or not data[0]:
 | 
				
			||||||
            return
 | 
					            return
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 
 | 
				
			|||||||
		Reference in New Issue
	
	Block a user