diff --git a/src/apps/competitions/models.py b/src/apps/competitions/models.py index 87b0b5513..6c994a1de 100644 --- a/src/apps/competitions/models.py +++ b/src/apps/competitions/models.py @@ -536,9 +536,10 @@ def soft_delete(self): detail.delete() # Remove record from DB # Clear the data field if no other submissions are using it - other_submissions_using_data = Submission.objects.filter(data=self.data).exclude(pk=self.pk).exists() - if not other_submissions_using_data: - self.data.delete() + if self.data: + other_submissions_using_data = Submission.objects.filter(data=self.data).exclude(pk=self.pk).exists() + if not other_submissions_using_data: + self.data.delete() # Clear the data field for this submission self.data = None @@ -554,11 +555,12 @@ def soft_delete(self): 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 self.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() + 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() diff --git a/src/static/riot/competitions/detail/submission_manager.tag b/src/static/riot/competitions/detail/submission_manager.tag index 441a6cf52..3f41a69eb 100644 --- a/src/static/riot/competitions/detail/submission_manager.tag +++ b/src/static/riot/competitions/detail/submission_manager.tag @@ -123,8 +123,15 @@ - -