Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Delete Uploaded Files on Challenge Deletion #256

Open
thebeanogamer opened this issue Feb 28, 2022 · 0 comments
Open

Delete Uploaded Files on Challenge Deletion #256

thebeanogamer opened this issue Feb 28, 2022 · 0 comments
Labels

Comments

@thebeanogamer
Copy link
Member

thebeanogamer commented Feb 28, 2022

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

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

No branches or pull requests

2 participants