Fix GSheet translated texts
Signed-off-by: Emmy D'Anello <emmy.danello@animath.fr>
This commit is contained in:
parent
d13ae89267
commit
5c3b3d26c8
|
@ -470,18 +470,19 @@ class Tournament(models.Model):
|
||||||
gc = gspread.service_account_from_dict(settings.GOOGLE_SERVICE_CLIENT)
|
gc = gspread.service_account_from_dict(settings.GOOGLE_SERVICE_CLIENT)
|
||||||
spreadsheet = gc.open_by_key(self.notes_sheet_id)
|
spreadsheet = gc.open_by_key(self.notes_sheet_id)
|
||||||
worksheets = spreadsheet.worksheets()
|
worksheets = spreadsheet.worksheets()
|
||||||
if _("Final ranking") not in [ws.title for ws in worksheets]:
|
if str(_("Final ranking")) not in [ws.title for ws in worksheets]:
|
||||||
worksheet = spreadsheet.add_worksheet(_("Final ranking"), 30, 10)
|
worksheet = spreadsheet.add_worksheet(str(_("Final ranking")), 30, 10)
|
||||||
else:
|
else:
|
||||||
worksheet = spreadsheet.worksheet(_("Final ranking"))
|
worksheet = spreadsheet.worksheet(str(_("Final ranking")))
|
||||||
|
|
||||||
if worksheet.index != self.pools.count():
|
if worksheet.index != self.pools.count():
|
||||||
worksheet.update_index(self.pools.count())
|
worksheet.update_index(self.pools.count())
|
||||||
|
|
||||||
header = [[_("Team"), _("Scores day 1"), _("Tweaks day 1"), _("Scores day 2"), _("Tweaks day 2")]
|
header = [[str(_("Team")), str(_("Scores day 1")), str(_("Tweaks day 1")),
|
||||||
+ ([_("Total D1 + D2"), _("Scores day 3"), _("Tweaks day 3")]
|
str(_("Scores day 2")), str(_("Tweaks day 2"))]
|
||||||
|
+ ([str(_("Total D1 + D2")), str(_("Scores day 3")), str(_("Tweaks day 3"))]
|
||||||
if settings.NB_ROUNDS >= 3 else [])
|
if settings.NB_ROUNDS >= 3 else [])
|
||||||
+ [_("Total"), _("Rank")]]
|
+ [str(_("Total")), str(_("Rank"))]]
|
||||||
lines = []
|
lines = []
|
||||||
participations = self.participations.filter(pools__round=1, pools__tournament=self).distinct().all()
|
participations = self.participations.filter(pools__round=1, pools__tournament=self).distinct().all()
|
||||||
total_col, rank_col = ("F", "G") if settings.NB_ROUNDS == 2 else ("I", "J")
|
total_col, rank_col = ("F", "G") if settings.NB_ROUNDS == 2 else ("I", "J")
|
||||||
|
@ -548,7 +549,8 @@ class Tournament(models.Model):
|
||||||
+ (f" + (PI() - 2) * $G{i + 2} + $H{i + 2}" if settings.NB_ROUNDS >= 3 else ""))
|
+ (f" + (PI() - 2) * $G{i + 2} + $H{i + 2}" if settings.NB_ROUNDS >= 3 else ""))
|
||||||
line.append(f"=RANG(${total_col}{i + 2}; ${total_col}$2:${total_col}${participations.count() + 1})")
|
line.append(f"=RANG(${total_col}{i + 2}; ${total_col}$2:${total_col}${participations.count() + 1})")
|
||||||
|
|
||||||
final_ranking = [["", "", "", ""], ["", "", "", ""], [_("Team"), _("Score"), _("Rank"), _("Mention")],
|
final_ranking = [["", "", "", ""], ["", "", "", ""],
|
||||||
|
[str(_("Team")), str(_("Score")), str(_("Rank")), str(_("Mention"))],
|
||||||
[f"=SORT($A$2:$A${participations.count() + 1}; "
|
[f"=SORT($A$2:$A${participations.count() + 1}; "
|
||||||
f"${total_col}$2:${total_col}${participations.count() + 1}; FALSE)",
|
f"${total_col}$2:${total_col}${participations.count() + 1}; FALSE)",
|
||||||
f"=SORT(${total_col}$2:${total_col}${participations.count() + 1}; "
|
f"=SORT(${total_col}$2:${total_col}${participations.count() + 1}; "
|
||||||
|
@ -693,7 +695,7 @@ class Tournament(models.Model):
|
||||||
"addProtectedRange": {
|
"addProtectedRange": {
|
||||||
"protectedRange": {
|
"protectedRange": {
|
||||||
"range": a1_range_to_grid_range(protected_range, worksheet.id),
|
"range": a1_range_to_grid_range(protected_range, worksheet.id),
|
||||||
"description": _("Don't update the table structure for a better automated integration."),
|
"description": str(_("Don't update the table structure for a better automated integration.")),
|
||||||
"warningOnly": True,
|
"warningOnly": True,
|
||||||
},
|
},
|
||||||
}
|
}
|
||||||
|
@ -711,9 +713,9 @@ class Tournament(models.Model):
|
||||||
|
|
||||||
gc = gspread.service_account_from_dict(settings.GOOGLE_SERVICE_CLIENT)
|
gc = gspread.service_account_from_dict(settings.GOOGLE_SERVICE_CLIENT)
|
||||||
spreadsheet = gc.open_by_key(self.notes_sheet_id)
|
spreadsheet = gc.open_by_key(self.notes_sheet_id)
|
||||||
worksheet = spreadsheet.worksheet(_("Final ranking"))
|
worksheet = spreadsheet.worksheet(str(_("Final ranking")))
|
||||||
|
|
||||||
score_cell = worksheet.find(_("Score"))
|
score_cell = worksheet.find(str(_("Score")))
|
||||||
max_row = score_cell.row - 3
|
max_row = score_cell.row - 3
|
||||||
if max_row == 1:
|
if max_row == 1:
|
||||||
# There is no team
|
# There is no team
|
||||||
|
@ -1231,18 +1233,18 @@ class Pool(models.Model):
|
||||||
passages = self.passages.all()
|
passages = self.passages.all()
|
||||||
|
|
||||||
header = [
|
header = [
|
||||||
sum(([_("Problem #{problem}").format(problem=passage.solution_number)] + (passage_width - 1) * [""]
|
sum(([str(_("Problem #{problem}").format(problem=passage.solution_number))] + (passage_width - 1) * [""]
|
||||||
for passage in passages), start=[_("Problem"), ""]),
|
for passage in passages), start=[str(_("Problem")), ""]),
|
||||||
sum(([f"{_('Defender')} ({passage.defender.team.trigram})", "",
|
sum(([f"{_('Defender')} ({passage.defender.team.trigram})", "",
|
||||||
f"{_('Opponent')} ({passage.opponent.team.trigram})", "",
|
f"{_('Opponent')} ({passage.opponent.team.trigram})", "",
|
||||||
f"{_('Reviewer')} ({passage.reviewer.team.trigram})", ""]
|
f"{_('Reviewer')} ({passage.reviewer.team.trigram})", ""]
|
||||||
+ ([f"{('Observer')} ({passage.observer.team.trigram})", ""] if has_observer else [])
|
+ ([f"{_('Observer')} ({passage.observer.team.trigram})", ""] if has_observer else [])
|
||||||
for passage in passages), start=["Rôle", ""]),
|
for passage in passages), start=[str(_("Role")), ""]),
|
||||||
sum(([f"{_('Writing')} (/{20 if settings.TFJM_APP == "TFJM" else 10})",
|
sum(([f"{_('Writing')} (/{20 if settings.TFJM_APP == "TFJM" else 10})",
|
||||||
f"{_('Oral')} (/{20 if settings.TFJM_APP == 'TFJM' else 10})"
|
f"{_('Oral')} (/{20 if settings.TFJM_APP == 'TFJM' else 10})",
|
||||||
f"{_('Writing')} (/10)", f"{_('Oral')} (/10)", f"{_('Writing')} (/10)", f"{_('Oral')} (/10)"]
|
f"{_('Writing')} (/10)", f"{_('Oral')} (/10)", f"{_('Writing')} (/10)", f"{_('Oral')} (/10)"]
|
||||||
+ ([f"{_('Writing')} (/10)", f"{_('Oral')} (/10)"] if has_observer else [])
|
+ ([f"{_('Writing')} (/10)", f"{_('Oral')} (/10)"] if has_observer else [])
|
||||||
for _passage in passages), start=[_("Juree"), ""]),
|
for _passage in passages), start=[str(_("Juree")), ""]),
|
||||||
]
|
]
|
||||||
|
|
||||||
notes = [[]] # Begin with empty hidden line to ensure pretty design
|
notes = [[]] # Begin with empty hidden line to ensure pretty design
|
||||||
|
@ -1265,14 +1267,14 @@ class Pool(models.Model):
|
||||||
return ''
|
return ''
|
||||||
return getcol((number - 1) // 26) + chr(65 + (number - 1) % 26)
|
return getcol((number - 1) // 26) + chr(65 + (number - 1) % 26)
|
||||||
|
|
||||||
average = [_("Average"), ""]
|
average = [str(_("Average")), ""]
|
||||||
coeffs = sum(([passage.coeff_defender_writing, passage.coeff_defender_oral,
|
coeffs = sum(([passage.coeff_defender_writing, passage.coeff_defender_oral,
|
||||||
passage.coeff_opponent_writing, passage.coeff_opponent_oral,
|
passage.coeff_opponent_writing, passage.coeff_opponent_oral,
|
||||||
passage.coeff_reviewer_writing, passage.coeff_reviewer_oral]
|
passage.coeff_reviewer_writing, passage.coeff_reviewer_oral]
|
||||||
+ ([passage.coeff_observer_writing, passage.coeff_observer_oral] if has_observer else [])
|
+ ([passage.coeff_observer_writing, passage.coeff_observer_oral] if has_observer else [])
|
||||||
for passage in passages),
|
for passage in passages),
|
||||||
start=[_("Coefficient"), ""])
|
start=[str(_("Coefficient")), ""])
|
||||||
subtotal = [_("Subtotal"), ""]
|
subtotal = [str(_("Subtotal")), ""]
|
||||||
footer = [average, coeffs, subtotal, 34 * [""]]
|
footer = [average, coeffs, subtotal, 34 * [""]]
|
||||||
|
|
||||||
min_row = 5
|
min_row = 5
|
||||||
|
@ -1306,7 +1308,7 @@ class Pool(models.Model):
|
||||||
f" + {obs_o_col}{max_row + 1} * {obs_o_col}{max_row + 2}", ""])
|
f" + {obs_o_col}{max_row + 1} * {obs_o_col}{max_row + 2}", ""])
|
||||||
|
|
||||||
ranking = [
|
ranking = [
|
||||||
[_("Team"), "", _("Problem"), _("Total"), _("Rank")],
|
[str(_("Team")), "", str(_("Problem")), str(_("Total")), str(_("Rank"))],
|
||||||
]
|
]
|
||||||
all_passages = Passage.objects.filter(pool__tournament=self.tournament,
|
all_passages = Passage.objects.filter(pool__tournament=self.tournament,
|
||||||
pool__round=self.round,
|
pool__round=self.round,
|
||||||
|
@ -1353,7 +1355,7 @@ class Pool(models.Model):
|
||||||
all_values = header + notes + footer + ranking
|
all_values = header + notes + footer + ranking
|
||||||
|
|
||||||
worksheet.batch_clear([f"A1:AH{max_row + 5 + pool_size}"])
|
worksheet.batch_clear([f"A1:AH{max_row + 5 + pool_size}"])
|
||||||
worksheet.update("A1:AH", all_values, raw=False)
|
worksheet.update(all_values, "A1:AH", raw=False)
|
||||||
|
|
||||||
format_requests = []
|
format_requests = []
|
||||||
|
|
||||||
|
@ -1372,6 +1374,11 @@ class Pool(models.Model):
|
||||||
f":{getcol(6 + i * passage_width)}{max_row + 3}")
|
f":{getcol(6 + i * passage_width)}{max_row + 3}")
|
||||||
merge_cells.append(f"{getcol(7 + i * passage_width)}{max_row + 3}"
|
merge_cells.append(f"{getcol(7 + i * passage_width)}{max_row + 3}"
|
||||||
f":{getcol(8 + i * passage_width)}{max_row + 3}")
|
f":{getcol(8 + i * passage_width)}{max_row + 3}")
|
||||||
|
|
||||||
|
if has_observer:
|
||||||
|
merge_cells.append(f"{getcol(9 + i * passage_width)}2:{getcol(10 + i * passage_width)}2")
|
||||||
|
merge_cells.append(f"{getcol(9 + i * passage_width)}{max_row + 3}"
|
||||||
|
f":{getcol(10 + i * passage_width)}{max_row + 3}")
|
||||||
merge_cells.append(f"A{max_row + 1}:B{max_row + 1}")
|
merge_cells.append(f"A{max_row + 1}:B{max_row + 1}")
|
||||||
merge_cells.append(f"A{max_row + 2}:B{max_row + 2}")
|
merge_cells.append(f"A{max_row + 2}:B{max_row + 2}")
|
||||||
merge_cells.append(f"A{max_row + 3}:B{max_row + 3}")
|
merge_cells.append(f"A{max_row + 3}:B{max_row + 3}")
|
||||||
|
@ -1532,8 +1539,8 @@ class Pool(models.Model):
|
||||||
"values": [{"userEnteredValue": f'=ET(REGEXMATCH(TO_TEXT({column}4); "^-?[0-9]+$"); '
|
"values": [{"userEnteredValue": f'=ET(REGEXMATCH(TO_TEXT({column}4); "^-?[0-9]+$"); '
|
||||||
f'{column}4>={min_note}; {column}4<={max_note})'},],
|
f'{column}4>={min_note}; {column}4<={max_note})'},],
|
||||||
},
|
},
|
||||||
"inputMessage": (_("Input must be a valid integer between {min_note} and {max_note}.")
|
"inputMessage": str(_("Input must be a valid integer between {min_note} and {max_note}.")
|
||||||
.format(min_note=min_note, max_note=max_note)),
|
.format(min_note=min_note, max_note=max_note)),
|
||||||
"strict": True,
|
"strict": True,
|
||||||
},
|
},
|
||||||
}
|
}
|
||||||
|
@ -1569,7 +1576,7 @@ class Pool(models.Model):
|
||||||
"addProtectedRange": {
|
"addProtectedRange": {
|
||||||
"protectedRange": {
|
"protectedRange": {
|
||||||
"range": a1_range_to_grid_range(protected_range, worksheet.id),
|
"range": a1_range_to_grid_range(protected_range, worksheet.id),
|
||||||
"description": _("Don't update the table structure for a better automated integration."),
|
"description": str(_("Don't update the table structure for a better automated integration.")),
|
||||||
"warningOnly": True,
|
"warningOnly": True,
|
||||||
},
|
},
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in New Issue