2020-01-21 06:35:58 +00:00
|
|
|
from . import registry
|
|
|
|
|
|
|
|
|
|
|
|
@registry.function
|
2022-05-14 17:57:27 +00:00
|
|
|
def submission_layout(
|
|
|
|
submission, profile_id, user, editable_problem_ids, completed_problem_ids
|
|
|
|
):
|
2020-01-21 06:35:58 +00:00
|
|
|
problem_id = submission.problem_id
|
|
|
|
can_view = False
|
|
|
|
|
|
|
|
if problem_id in editable_problem_ids:
|
|
|
|
can_view = True
|
|
|
|
|
|
|
|
if profile_id == submission.user_id:
|
|
|
|
can_view = True
|
|
|
|
|
2022-05-14 17:57:27 +00:00
|
|
|
if user.has_perm("judge.change_submission"):
|
2020-01-21 06:35:58 +00:00
|
|
|
can_view = True
|
|
|
|
|
|
|
|
if submission.problem_id in completed_problem_ids:
|
2022-05-14 17:57:27 +00:00
|
|
|
can_view |= (
|
|
|
|
submission.problem.is_public or profile_id in submission.problem.tester_ids
|
|
|
|
)
|
2020-01-21 06:35:58 +00:00
|
|
|
|
2022-05-14 17:57:27 +00:00
|
|
|
if not can_view and hasattr(submission, "contest"):
|
2022-04-29 19:36:26 +00:00
|
|
|
contest = submission.contest.participation.contest
|
|
|
|
if contest.is_editable_by(user):
|
|
|
|
can_view = True
|
|
|
|
|
2020-01-21 06:35:58 +00:00
|
|
|
return can_view
|