Skip to content

Commit 353f603

Browse files
authored
Merge pull request #2446 from codalab/delete-submissions
fix: allow organizers to hard-delete soft-deleted submissions
2 parents 7c1bb92 + 445079e commit 353f603

2 files changed

Lines changed: 18 additions & 9 deletions

File tree

src/apps/competitions/models.py

Lines changed: 9 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -536,9 +536,10 @@ def soft_delete(self):
536536
detail.delete() # Remove record from DB
537537

538538
# Clear the data field if no other submissions are using it
539-
other_submissions_using_data = Submission.objects.filter(data=self.data).exclude(pk=self.pk).exists()
540-
if not other_submissions_using_data:
541-
self.data.delete()
539+
if self.data:
540+
other_submissions_using_data = Submission.objects.filter(data=self.data).exclude(pk=self.pk).exists()
541+
if not other_submissions_using_data:
542+
self.data.delete()
542543

543544
# Clear the data field for this submission
544545
self.data = None
@@ -554,11 +555,12 @@ def soft_delete(self):
554555
def delete(self, **kwargs):
555556

556557
# Check if any other submissions are using the same data
557-
other_submissions_using_data = Submission.objects.filter(data=self.data).exclude(pk=self.pk).exists()
558+
if self.data:
559+
other_submissions_using_data = Submission.objects.filter(data=self.data).exclude(pk=self.pk).exists()
558560

559-
if not other_submissions_using_data:
560-
# If no other submissions are using the same data, delete it
561-
self.data.delete()
561+
if not other_submissions_using_data:
562+
# If no other submissions are using the same data, delete it
563+
self.data.delete()
562564

563565
# Also clean up details on delete
564566
self.details.all().delete()

src/static/riot/competitions/detail/submission_manager.tag

Lines changed: 9 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -123,8 +123,15 @@
123123
</a>
124124
</td>
125125
<!-- Show Action buttons when submission is not soft deleted -->
126-
<!-- Otherwise show empty <td> -->
127-
<td if="{ submission.is_soft_deleted }"></td>
126+
<!-- For soft-deleted submissions, organizers can still hard-delete -->
127+
<td if="{ submission.is_soft_deleted }">
128+
<virtual if="{ opts.admin }">
129+
<span data-tooltip="Delete Submission" data-inverted=""
130+
onclick="{ delete_submission.bind(this, submission) }">
131+
<i class="icon red trash alternate"></i>
132+
</span>
133+
</virtual>
134+
</td>
128135
<td class="center aligned" if="{ !submission.is_soft_deleted }">
129136
<virtual if="{ opts.admin}">
130137
<!-- run/rerun submission -->

0 commit comments

Comments
 (0)