Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 2 additions & 0 deletions src/apps/api/serializers/competitions.py
Original file line number Diff line number Diff line change
Expand Up @@ -43,6 +43,7 @@ class Meta:
'max_submissions_per_person',
'auto_migrate_to_this_phase',
'hide_output',
'hide_score_output',
'leaderboard',
'public_data',
'starting_kit',
Expand Down Expand Up @@ -124,6 +125,7 @@ class Meta:
'max_submissions_per_person',
'auto_migrate_to_this_phase',
'hide_output',
'hide_score_output',
# no leaderboard
'public_data',
'starting_kit',
Expand Down
2 changes: 1 addition & 1 deletion src/apps/api/serializers/submissions.py
Original file line number Diff line number Diff line change
Expand Up @@ -271,7 +271,7 @@ def get_detailed_result(self, instance):

def get_scoring_result(self, instance):
if instance.scoring_result.name:
if instance.phase.hide_output and not instance.phase.competition.user_has_admin_permission(self.context['request'].user):
if (instance.phase.hide_output or instance.phase.hide_score_output) and not instance.phase.competition.user_has_admin_permission(self.context['request'].user):
return None
return make_url_sassy(instance.scoring_result.name)

Expand Down
1 change: 1 addition & 0 deletions src/apps/api/views/competitions.py
Original file line number Diff line number Diff line change
Expand Up @@ -275,6 +275,7 @@ def update(self, request, *args, **kwargs):
name=phase["name"],
description=phase["description"],
hide_output=phase["hide_output"],
hide_score_output=phase["hide_score_output"],
competition=Competition.objects.get(id=data['id'])
)
# Get phase id
Expand Down
18 changes: 18 additions & 0 deletions src/apps/competitions/migrations/0054_auto_20250321_1341.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,18 @@
# Generated by Django 2.2.28 on 2025-03-21 13:41

from django.db import migrations, models


class Migration(migrations.Migration):

dependencies = [
('competitions', '0053_auto_20250218_1151'),
]

operations = [
migrations.AlterField(
model_name='submissiondetails',
name='file_size',
field=models.DecimalField(blank=True, decimal_places=2, max_digits=15, null=True),
),
]
14 changes: 14 additions & 0 deletions src/apps/competitions/migrations/0056_merge_20250324_2128.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
# Generated by Django 2.2.28 on 2025-03-24 21:28

from django.db import migrations


class Migration(migrations.Migration):

dependencies = [
('competitions', '0054_auto_20250321_1341'),
('competitions', '0055_merge_20250324_0650'),
]

operations = [
]
18 changes: 18 additions & 0 deletions src/apps/competitions/migrations/0057_phase_hide_score_output.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,18 @@
# Generated by Django 2.2.28 on 2025-04-25 09:59

from django.db import migrations, models


class Migration(migrations.Migration):

dependencies = [
('competitions', '0056_merge_20250324_2128'),
]

operations = [
migrations.AddField(
model_name='phase',
name='hide_score_output',
field=models.BooleanField(default=False),
),
]
1 change: 1 addition & 0 deletions src/apps/competitions/models.py
Original file line number Diff line number Diff line change
Expand Up @@ -342,6 +342,7 @@ class Phase(ChaHubSaveMixin, models.Model):
auto_migrate_to_this_phase = models.BooleanField(default=False)
has_been_migrated = models.BooleanField(default=False)
hide_output = models.BooleanField(default=False)
hide_score_output = models.BooleanField(default=False)

has_max_submissions = models.BooleanField(default=True)
max_submissions_per_day = models.PositiveIntegerField(default=5, null=True, blank=True)
Expand Down
1 change: 1 addition & 0 deletions src/apps/competitions/tasks.py
Original file line number Diff line number Diff line change
Expand Up @@ -82,6 +82,7 @@
'execution_time_limit',
'auto_migrate_to_this_phase',
'hide_output',
'hide_score_output',
]
PHASE_FILES = [
"input_data",
Expand Down
12 changes: 4 additions & 8 deletions src/apps/competitions/tests/unpacker_test_data.py
Original file line number Diff line number Diff line change
Expand Up @@ -213,6 +213,8 @@
'starting_kit': None,
'tasks': [0],
'status': 'Previous',
'hide_output': False,
'hide_score_output': False,
},
{
'index': 1,
Expand All @@ -230,14 +232,11 @@
'tasks': [1],
'status': 'Current',
'is_final_phase': True,
'hide_output': False,
'hide_score_output': False,
}
]

V2_SPECIFIC_PHASE_DATA = [
# Tuples of (key, value) of data specific to v2 unpacker.
('hide_output', False)
]


def get_phases(version):
if version == 1:
Expand All @@ -246,9 +245,6 @@ def get_phases(version):
# Make a copy of the list so we aren't mutating the original phases object. May not be strictly necessary,
# but if we ever write a test comparing v1 to v2 or something, this would avoid bugs.
v2 = [{k: v for k, v in phase.items()} for phase in PHASES]
for phase in v2:
for key, value in V2_SPECIFIC_PHASE_DATA:
phase[key] = value
return v2


Expand Down
2 changes: 2 additions & 0 deletions src/apps/competitions/unpackers/v1.py
Original file line number Diff line number Diff line change
Expand Up @@ -88,6 +88,8 @@ def _unpack_phases(self):
'max_submissions_per_day': phase.get('max_submissions_per_day', 5),
'max_submissions_per_person': phase.get('max_submissions', 100),
'auto_migrate_to_this_phase': phase.get('auto_migration', False),
'hide_output': phase.get('hide_output', False),
'hide_score_output': phase.get('hide_score_output', False),
}
execution_time_limit = phase.get('execution_time_limit')
if execution_time_limit:
Expand Down
1 change: 1 addition & 0 deletions src/apps/competitions/unpackers/v2.py
Original file line number Diff line number Diff line change
Expand Up @@ -198,6 +198,7 @@ def _unpack_phases(self):
'max_submissions_per_person': phase_data.get('max_submissions', 100),
'auto_migrate_to_this_phase': phase_data.get('auto_migrate_to_this_phase', False),
'hide_output': phase_data.get('hide_output', False),
'hide_score_output': phase_data.get('hide_score_output', False),
}
try:
new_phase['tasks'] = phase_data['tasks']
Expand Down
2 changes: 1 addition & 1 deletion src/static/riot/competitions/detail/submission_modal.tag
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,7 @@
</td>
</tr>
<tr>
<td class="selectable file-download {disabled: !scoring_result}">
<td class="selectable file-download {disabled: !scoring_result}" show="{!opts.hide_score_output}">
<a href="{ scoring_result }"><i class="file outline icon"></i>Output from scoring step</a>
</td>
</tr>
Expand Down
18 changes: 15 additions & 3 deletions src/static/riot/competitions/editor/_phases.tag
Original file line number Diff line number Diff line change
Expand Up @@ -190,10 +190,22 @@
</div>
<div class="field">
<div class="ui checkbox">
<label>Hide Submission Output</label>
<label>Hide Submission Output
<span data-tooltip="Hide all submission output" data-inverted=""
data-position="bottom center"><i class="help icon circle"></i></span>
</label>
<input type="checkbox" ref="hide_output">
</div>
</div>
<div class="field">
<div class="ui checkbox">
<label>Hide Score Output
<span data-tooltip="Prevent participants from downloading 'Output from scoring step'" data-inverted=""
data-position="bottom center"><i class="help icon circle"></i></span>
</label>
<input type="checkbox" ref="hide_score_output">
</div>
</div>

<div class="inline field" if="{phases.length > 0 && ![null, undefined, 0].includes(selected_phase_index)}">
<div class="ui checkbox">
Expand Down Expand Up @@ -641,19 +653,18 @@
return new Date(Date.parse(date))
}


self.edit = function (index) {
self.selected_phase_index = index
var phase = self.phases[index]
self.phase_tasks = phase.tasks
self.phase_public_data = [phase.public_data]
self.phase_starting_kit = [phase.starting_kit]


self.update()
set_form_data(phase, self.refs.form)
$(self.refs.auto_migrate).prop('checked', _.get(phase, 'auto_migrate_to_this_phase', false))
self.refs.hide_output.checked = phase.hide_output
self.refs.hide_score_output.checked = phase.hide_score_output

// Setting description in markdown editor
self.simple_markdown_editor.value(self.phases[index].description || '')
Expand Down Expand Up @@ -812,6 +823,7 @@
}
data.auto_migrate_to_this_phase = $(self.refs.auto_migrate).prop('checked')
data.hide_output = self.refs.hide_output.checked
data.hide_score_output = self.refs.hide_score_output.checked
_.forEach(number_fields, field => {
let str = _.get(data, field)
if (str) {
Expand Down