Skip to content
Snippets Groups Projects
Commit cf9dbac3 authored by Martin Mareš's avatar Martin Mareš
Browse files

Rozdělena práva k výsledkovce na view_contestants a view_submits

parent 2b4c8634
No related branches found
No related tags found
1 merge request!95Reforma orgovského rozhraní ke kolům a soutěžím
......@@ -43,11 +43,13 @@ class SolPointsCell(Cell):
contest_id: int
user: db.User
sol: Optional[db.Solution]
link_to_paper: bool
def __init__(self, contest_id: int, user: db.User, sol: Optional[db.Solution]):
def __init__(self, contest_id: int, user: db.User, sol: Optional[db.Solution], link_to_paper: bool):
self.contest_id = contest_id
self.user = user
self.sol = sol
self.link_to_paper = link_to_paper
def __str__(self) -> str:
if not self.sol:
......@@ -64,7 +66,9 @@ class SolPointsCell(Cell):
else:
points = format_decimal(self.sol.points)
if self.sol.final_feedback_obj:
if not self.link_to_paper:
return f'<td>{points}'
elif self.sol.final_feedback_obj:
url = mo.web.util.org_paper_link(self.contest_id, None, self.user, self.sol.final_feedback_obj)
return f'<td><a href="{url}" title="Zobrazit finální opravu">{points}</a>'
elif self.sol.final_submit_obj:
......@@ -84,9 +88,9 @@ def org_score(round_id: Optional[int] = None, ct_id: Optional[int] = None):
sess = db.get_session()
# FIXME
if not ctx.rights.have_right(Right.view_submits):
if not ctx.rights.have_right(Right.view_contestants):
raise werkzeug.exceptions.Forbidden()
can_view_submits = ctx.rights.have_right(Right.view_submits)
score = Score(round.master, contest)
tasks = score.get_tasks()
......@@ -175,7 +179,8 @@ def org_score(round_id: Optional[int] = None, ct_id: Optional[int] = None):
for task in tasks:
local_sol_ct_id = subcontest_id_map[(task.round_id, pion.contest_id)]
row.keys[f'task_{task.task_id}'] = SolPointsCell(
contest_id=local_sol_ct_id, user=user, sol=sols.get(task.task_id)
contest_id=local_sol_ct_id, user=user, sol=sols.get(task.task_id),
link_to_paper=can_view_submits
)
if result.winner:
row.html_attr = {"class": "winner", "title": "Vítěz"}
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment