From 1dfc6d312d4bef1aa8666acc87a2c82e4d89f69f Mon Sep 17 00:00:00 2001 From: cuom1999 Date: Fri, 29 Apr 2022 14:36:26 -0500 Subject: [PATCH] Allow contest host to view submissions --- judge/jinja2/submission.py | 5 +++++ judge/views/submission.py | 4 ++++ 2 files changed, 9 insertions(+) diff --git a/judge/jinja2/submission.py b/judge/jinja2/submission.py index f1d352e..47765b2 100644 --- a/judge/jinja2/submission.py +++ b/judge/jinja2/submission.py @@ -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 diff --git a/judge/views/submission.py b/judge/views/submission.py index a292998..d10da79 100644 --- a/judge/views/submission.py +++ b/judge/views/submission.py @@ -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):