Skip to content
Snippets Groups Projects
Commit c47a0c4b authored by Jan Prachař's avatar Jan Prachař
Browse files

Rights: Funkce, která vrátí důvod, proč se nezobrazilo zadání

parent e286d393
No related branches found
No related tags found
1 merge request!65Tabulka Moje soutěže
......@@ -281,6 +281,24 @@ class ContestRights(Rights):
def can_view_statement(self) -> bool:
return self._check_view_statement(self.contest.round)
def cannot_view_statement_reason(self) -> str:
round = self.contest.round
if round.tasks_file is None:
return "zatím chybí"
if self.have_right(Right.manage_round):
# Správce kola může vždy všechno
return ""
if self.have_right(Right.view_statement):
if round.state == db.RoundState.preparing:
return "až začne soutěž"
if round.state == db.RoundState.running and round.pr_tasks_start is None:
return "až začnou opravy"
if mo.now < round.pr_tasks_start:
return mo.util_format.timedelta(round.pr_tasks_start)
if round.state not in [db.RoundState.grading, db.RoundState.closed]:
return "až začnou opravy"
return ""
class Gatekeeper:
"""Dveřník rozhoduje, jaká práva má uživatel k danému objektu.
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment