diff --git a/oioioi/contests/templates/contests/submission_header.html b/oioioi/contests/templates/contests/submission_header.html index 89ff4c9c3..b92578d67 100644 --- a/oioioi/contests/templates/contests/submission_header.html +++ b/oioioi/contests/templates/contests/submission_header.html @@ -49,11 +49,13 @@ {% endif %} {% block controls_buttons %} {% if contest %} - - - {% trans "Submit another" %} + {% if not is_contest_archived %} + + + {% trans "Submit another" %} + {% endif %} {% else %} {% if submission.submission.problem_instance.problem.problemsite %} diff --git a/oioioi/contests/tests/tests.py b/oioioi/contests/tests/tests.py index 8410b3955..e12c5ac5d 100755 --- a/oioioi/contests/tests/tests.py +++ b/oioioi/contests/tests/tests.py @@ -4166,6 +4166,21 @@ def test_dashboard_view(self): self.assertContains(response, "This contest is archived.") self.assertNotContains(response, "Submit") + def test_submissions_view(self): + self.assertTrue(self.client.login(username='test_user')) + url = reverse('my_submissions', kwargs={'contest_id': 'c'}) + response = self.client.get(url) + self.assertEqual(response.status_code, 200) + self.assertNotContains(response, "Submit") + + def test_submission_view(self): + contest = Contest.objects.get() + submission = Submission.objects.get(pk=1) + self.assertTrue(self.client.login(username='test_user')) + kwargs = {'contest_id': contest.id, 'submission_id': submission.id} + response = self.client.get(reverse('submission', kwargs=kwargs)) + self.assertNotContains(response, "Submit") + def test_submission_list_visibility(self): self.assertTrue(self.client.login(username='test_user')) url = reverse('my_submissions', kwargs={'contest_id': 'c'}) diff --git a/oioioi/contests/utils.py b/oioioi/contests/utils.py index 646f34156..8495f8b0c 100755 --- a/oioioi/contests/utils.py +++ b/oioioi/contests/utils.py @@ -614,6 +614,7 @@ def get_submission_message(request): def is_contest_archived(request): return ( hasattr(request, 'contest') + and (request.contest is not None) and request.contest.is_archived ) diff --git a/oioioi/programs/controllers.py b/oioioi/programs/controllers.py index 91b4039f7..401a22ee8 100644 --- a/oioioi/programs/controllers.py +++ b/oioioi/programs/controllers.py @@ -23,6 +23,7 @@ is_contest_admin, is_contest_basicadmin, is_contest_observer, + is_contest_archived, get_submission_message, ) from oioioi.evalmgr.tasks import ( @@ -703,6 +704,7 @@ def render_submission(self, request, submission): submission ), 'can_admin': can_admin, + 'is_contest_archived': is_contest_archived(request), 'message': get_submission_message(request), }, )