Skip to content
Merged
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
11 changes: 9 additions & 2 deletions src/apps/competitions/models.py
Original file line number Diff line number Diff line change
Expand Up @@ -500,10 +500,17 @@ def __str__(self):
return f"{self.phase.competition.title} submission PK={self.pk} by {self.owner.username}"

def delete(self, **kwargs):

# Check if any other submissions are using the same data
other_submissions_using_data = Submission.objects.filter(data=self.data).exclude(pk=self.pk).exists()

if not other_submissions_using_data:
# If no other submissions are using the same data, delete it
self.data.delete()

# Also clean up details on delete
self.details.all().delete()
# Call this here so that the data_file for the submission also gets deleted from storage
self.data.delete()

super().delete(**kwargs)

def save(self, ignore_submission_limit=False, **kwargs):
Expand Down