NDOJ/judge/jinja2/submission.py

42 lines
957 B
Python
Raw Normal View History

2020-01-21 06:35:58 +00:00
from . import registry
@registry.function
2022-05-14 17:57:27 +00:00
def submission_layout(
2023-02-18 22:38:47 +00:00
submission,
profile_id,
user,
editable_problem_ids,
completed_problem_ids,
tester_problem_ids,
2022-05-14 17:57:27 +00:00
):
2020-01-21 06:35:58 +00:00
problem_id = submission.problem_id
if problem_id in editable_problem_ids:
2023-02-18 22:38:47 +00:00
return True
if problem_id in tester_problem_ids:
return True
2020-01-21 06:35:58 +00:00
if profile_id == submission.user_id:
2023-02-18 22:38:47 +00:00
return True
2020-01-21 06:35:58 +00:00
2022-05-14 17:57:27 +00:00
if user.has_perm("judge.change_submission"):
2023-02-18 22:38:47 +00:00
return True
2020-01-21 06:35:58 +00:00
2022-06-16 07:46:29 +00:00
if user.has_perm("judge.view_all_submission"):
2023-02-18 22:38:47 +00:00
return True
2022-06-16 07:46:29 +00:00
2022-06-16 07:56:02 +00:00
if submission.problem.is_public and user.has_perm("judge.view_public_submission"):
2023-02-18 22:38:47 +00:00
return True
2020-01-21 06:35:58 +00:00
2023-02-18 22:38:47 +00:00
if hasattr(submission, "contest"):
2022-04-29 19:36:26 +00:00
contest = submission.contest.participation.contest
if contest.is_editable_by(user):
2023-02-18 22:38:47 +00:00
return True
if submission.problem_id in completed_problem_ids and submission.problem.is_public:
return True
2022-04-29 19:36:26 +00:00
2023-02-18 22:38:47 +00:00
return False