Skip to content

Delete Uploaded Files on Challenge Deletion #256

@thebeanogamer

Description

@thebeanogamer

We've already got code to delete a file, we just need to make sure we're doing it when cascading down from a deleted challenge.

core/src/challenge/views.py

Lines 429 to 434 in aef1c79

def destroy(self, request: Request, *args, **kwargs) -> Response:
"""If the file was uploaded, delete the FileField on the model first."""
file: File = self.get_object()
if file.upload:
file.upload.delete(save=False)
return super().destroy(request, *args, **kwargs)

https://docs.djangoproject.com/en/4.0/ref/models/fields/#django.db.models.CASCADE

Metadata

Metadata

Assignees

No one assigned

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions