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)
|
||||
spreadsheet = gc.open_by_key(self.notes_sheet_id)
|
||||
worksheets = spreadsheet.worksheets()
|
||||
if _("Final ranking") not in [ws.title for ws in worksheets]:
|
||||
worksheet = spreadsheet.add_worksheet(_("Final ranking"), 30, 10)
|
||||
if str(_("Final ranking")) not in [ws.title for ws in worksheets]:
|
||||
worksheet = spreadsheet.add_worksheet(str(_("Final ranking")), 30, 10)
|
||||
else:
|
||||
worksheet = spreadsheet.worksheet(_("Final ranking"))
|
||||
worksheet = spreadsheet.worksheet(str(_("Final ranking")))
|
||||
|
||||
if worksheet.index != self.pools.count():
|
||||
worksheet.update_index(self.pools.count())
|
||||
|
||||
header = [[_("Team"), _("Scores day 1"), _("Tweaks day 1"), _("Scores day 2"), _("Tweaks day 2")]
|
||||
+ ([_("Total D1 + D2"), _("Scores day 3"), _("Tweaks day 3")]
|
||||
header = [[str(_("Team")), str(_("Scores day 1")), str(_("Tweaks day 1")),
|
||||
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 [])
|
||||
+ [_("Total"), _("Rank")]]
|
||||
+ [str(_("Total")), str(_("Rank"))]]
|
||||
lines = []
|
||||
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")
|
||||
|
@ -548,7 +549,8 @@ class Tournament(models.Model):
|
|||
+ (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})")
|
||||
|
||||
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"${total_col}$2:${total_col}${participations.count() + 1}; FALSE)",
|
||||
f"=SORT(${total_col}$2:${total_col}${participations.count() + 1}; "
|
||||
|
@ -693,7 +695,7 @@ class Tournament(models.Model):
|
|||
"addProtectedRange": {
|
||||
"protectedRange": {
|
||||
"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,
|
||||
},
|
||||
}
|
||||
|
@ -711,9 +713,9 @@ class Tournament(models.Model):
|
|||
|
||||
gc = gspread.service_account_from_dict(settings.GOOGLE_SERVICE_CLIENT)
|
||||
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
|
||||
if max_row == 1:
|
||||
# There is no team
|
||||
|
@ -1231,18 +1233,18 @@ class Pool(models.Model):
|
|||
passages = self.passages.all()
|
||||
|
||||
header = [
|
||||
sum(([_("Problem #{problem}").format(problem=passage.solution_number)] + (passage_width - 1) * [""]
|
||||
for passage in passages), start=[_("Problem"), ""]),
|
||||
sum(([str(_("Problem #{problem}").format(problem=passage.solution_number))] + (passage_width - 1) * [""]
|
||||
for passage in passages), start=[str(_("Problem")), ""]),
|
||||
sum(([f"{_('Defender')} ({passage.defender.team.trigram})", "",
|
||||
f"{_('Opponent')} ({passage.opponent.team.trigram})", "",
|
||||
f"{_('Reviewer')} ({passage.reviewer.team.trigram})", ""]
|
||||
+ ([f"{('Observer')} ({passage.observer.team.trigram})", ""] if has_observer else [])
|
||||
for passage in passages), start=["Rôle", ""]),
|
||||
+ ([f"{_('Observer')} ({passage.observer.team.trigram})", ""] if has_observer else [])
|
||||
for passage in passages), start=[str(_("Role")), ""]),
|
||||
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)"] 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
|
||||
|
@ -1265,14 +1267,14 @@ class Pool(models.Model):
|
|||
return ''
|
||||
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,
|
||||
passage.coeff_opponent_writing, passage.coeff_opponent_oral,
|
||||
passage.coeff_reviewer_writing, passage.coeff_reviewer_oral]
|
||||
+ ([passage.coeff_observer_writing, passage.coeff_observer_oral] if has_observer else [])
|
||||
for passage in passages),
|
||||
start=[_("Coefficient"), ""])
|
||||
subtotal = [_("Subtotal"), ""]
|
||||
start=[str(_("Coefficient")), ""])
|
||||
subtotal = [str(_("Subtotal")), ""]
|
||||
footer = [average, coeffs, subtotal, 34 * [""]]
|
||||
|
||||
min_row = 5
|
||||
|
@ -1306,7 +1308,7 @@ class Pool(models.Model):
|
|||
f" + {obs_o_col}{max_row + 1} * {obs_o_col}{max_row + 2}", ""])
|
||||
|
||||
ranking = [
|
||||
[_("Team"), "", _("Problem"), _("Total"), _("Rank")],
|
||||
[str(_("Team")), "", str(_("Problem")), str(_("Total")), str(_("Rank"))],
|
||||
]
|
||||
all_passages = Passage.objects.filter(pool__tournament=self.tournament,
|
||||
pool__round=self.round,
|
||||
|
@ -1353,7 +1355,7 @@ class Pool(models.Model):
|
|||
all_values = header + notes + footer + ranking
|
||||
|
||||
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 = []
|
||||
|
||||
|
@ -1372,6 +1374,11 @@ class Pool(models.Model):
|
|||
f":{getcol(6 + 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}")
|
||||
|
||||
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 + 2}:B{max_row + 2}")
|
||||
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]+$"); '
|
||||
f'{column}4>={min_note}; {column}4<={max_note})'},],
|
||||
},
|
||||
"inputMessage": (_("Input must be a valid integer between {min_note} and {max_note}.")
|
||||
.format(min_note=min_note, max_note=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)),
|
||||
"strict": True,
|
||||
},
|
||||
}
|
||||
|
@ -1569,7 +1576,7 @@ class Pool(models.Model):
|
|||
"addProtectedRange": {
|
||||
"protectedRange": {
|
||||
"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,
|
||||
},
|
||||
}
|
||||
|
|
Loading…
Reference in New Issue