NDOJ/judge/jinja2/submission.py

42 lines
957 B
Python
Raw Normal View History

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