Skip to content

Commit 20c3aec

Browse files
authored
Allow admins to see unpublished test packages (#233)
1 parent 6518a0e commit 20c3aec

File tree

3 files changed

+21
-2
lines changed

3 files changed

+21
-2
lines changed

oioioi/problems/templates/problems/files.html

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -20,7 +20,7 @@
2020
</thead>
2121
<tbody>
2222
{% for file in files %}
23-
<tr>
23+
<tr {% if not file.pub_date or file.pub_date > request.timestamp %} class="text-muted" {% endif %}>
2424
{% if add_category_field %}
2525
<td>{{ file.category }}</td>
2626
{% endif %}

oioioi/testspackages/tests.py

Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -137,3 +137,18 @@ def test_packages_visibility(self):
137137
with fake_time(datetime(2012, 8, 5, 0, 12, tzinfo=timezone.utc)):
138138
response = self.client.get(url)
139139
self.assertEqual(200, response.status_code)
140+
141+
self.assertTrue(self.client.login(username='test_admin'))
142+
url = reverse('contest_files', kwargs={'contest_id': contest.id})
143+
# Admins should see even unpublished test packages
144+
with fake_time(datetime(2012, 8, 5, 0, 10, tzinfo=timezone.utc)):
145+
response = self.client.get(url)
146+
self.assertContains(response, 'some_name.zip')
147+
self.assertContains(response, 'some_name2.zip')
148+
self.assertEqual(200, response.status_code)
149+
150+
with fake_time(datetime(2012, 8, 5, 1, 12, tzinfo=timezone.utc)):
151+
response = self.client.get(url)
152+
self.assertContains(response, 'some_name.zip')
153+
self.assertContains(response, 'some_name2.zip')
154+
self.assertEqual(200, response.status_code)

oioioi/testspackages/views.py

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -15,6 +15,7 @@
1515
can_enter_contest,
1616
contest_exists,
1717
is_contest_admin,
18+
is_contest_basicadmin,
1819
visible_problem_instances,
1920
)
2021
from oioioi.contests.models import ProblemInstance
@@ -30,7 +31,10 @@ def visible_tests_packages(request):
3031
return [
3132
tp
3233
for tp in tests_packages
33-
if tp.is_visible(request.timestamp) and tp.package is not None
34+
if tp.package is not None and (
35+
is_contest_basicadmin(request) or
36+
tp.is_visible(request.timestamp)
37+
)
3438
]
3539

3640

0 commit comments

Comments
 (0)