Allow contest host to view submissions

This commit is contained in:
cuom1999 2022-04-29 14:36:26 -05:00
parent f095729cb6
commit 1dfc6d312d
2 changed files with 9 additions and 0 deletions

View file

@ -18,4 +18,9 @@ def submission_layout(submission, profile_id, user, editable_problem_ids, comple
if submission.problem_id in completed_problem_ids:
can_view |= submission.problem.is_public or profile_id in submission.problem.tester_ids
if not can_view and hasattr(submission, 'contest'):
contest = submission.contest.participation.contest
if contest.is_editable_by(user):
can_view = True
return can_view

View file

@ -77,6 +77,10 @@ class SubmissionDetailBase(LoginRequiredMixin, TitleMixin, SubmissionMixin, Deta
if Submission.objects.filter(user_id=profile.id, result='AC', problem_id=problem.id,
points=problem.points).exists():
return submission
if (hasattr(submission, 'contest') and
submission.contest.participation.contest.is_editable_by(self.request.user)):
return submission
raise PermissionDenied()
def get_title(self):