diff --git a/oioioi/problems/templates/problems/files.html b/oioioi/problems/templates/problems/files.html index 1e97b2246..3f679a398 100644 --- a/oioioi/problems/templates/problems/files.html +++ b/oioioi/problems/templates/problems/files.html @@ -20,7 +20,7 @@ {% for file in files %} - + request.timestamp %} class="text-muted" {% endif %}> {% if add_category_field %} {{ file.category }} {% endif %} diff --git a/oioioi/testspackages/tests.py b/oioioi/testspackages/tests.py index 6d48c288d..a357fc15c 100644 --- a/oioioi/testspackages/tests.py +++ b/oioioi/testspackages/tests.py @@ -137,3 +137,18 @@ def test_packages_visibility(self): with fake_time(datetime(2012, 8, 5, 0, 12, tzinfo=timezone.utc)): response = self.client.get(url) self.assertEqual(200, response.status_code) + + self.assertTrue(self.client.login(username='test_admin')) + url = reverse('contest_files', kwargs={'contest_id': contest.id}) + # Admins should see even unpublished test packages + with fake_time(datetime(2012, 8, 5, 0, 10, tzinfo=timezone.utc)): + response = self.client.get(url) + self.assertContains(response, 'some_name.zip') + self.assertContains(response, 'some_name2.zip') + self.assertEqual(200, response.status_code) + + with fake_time(datetime(2012, 8, 5, 1, 12, tzinfo=timezone.utc)): + response = self.client.get(url) + self.assertContains(response, 'some_name.zip') + self.assertContains(response, 'some_name2.zip') + self.assertEqual(200, response.status_code) diff --git a/oioioi/testspackages/views.py b/oioioi/testspackages/views.py index 4708c1c48..dcc5512b8 100644 --- a/oioioi/testspackages/views.py +++ b/oioioi/testspackages/views.py @@ -15,6 +15,7 @@ can_enter_contest, contest_exists, is_contest_admin, + is_contest_basicadmin, visible_problem_instances, ) from oioioi.contests.models import ProblemInstance @@ -30,7 +31,10 @@ def visible_tests_packages(request): return [ tp for tp in tests_packages - if tp.is_visible(request.timestamp) and tp.package is not None + if tp.package is not None and ( + is_contest_basicadmin(request) or + tp.is_visible(request.timestamp) + ) ]