Skip to content

Submission Delete - clean up everything when a submission is deleted - #2629

Merged
Didayolo merged 4 commits into
developfrom
submission_delete_cleanup
Nov 19, 2026
Merged

Didayolo merged 4 commits into
developfrom
submission_delete_cleanup

Conversation

@ihsaan-ullah

@ihsaan-ullah ihsaan-ullah commented Oct 8, 2026 •

Copy link
Copy Markdown
Collaborator

Description

  • Delete child submissions, scores, logs, zips and files with a submission
  • Keep a zip when another submission still uses it
  • Soft delete also cleans up child submissions, keeping only the records
  • Delete failed submissions now cleans up everything and updates counts
  • Failed submissions counter no longer counts child submissions
  • Clearer messages before deleting submissions
  • Add tests for deleting, soft deleting and deleting failed submissions

NOTE

This should be reviewed and tested carefully because it involves deletion of data and files

Issues this PR resolves

How to test

Step 1: Upload

NOTE: note down the submission ID you want to delete

Step 2: Submission delete preview

Run this script to get a preview of what fields and files are associated with a submission: check_submission_delete_preview.py

Run the script using the command:

docker compose exec -T \
    -e SUB_IDS=<SUB_ID>\
    django \
    python manage.py shell \
    -c "$(cat check_submission_delete_preview.py)" \
    | tee preview.txt

NOTE: this script saves the output in preview.txt

Step 3: Submission delete

Delete your submission in one of the places:

  • Hard delete by organizer from the submission manager
  • Soft delete by participant from the submission manager
  • Hard delete by participant from the resrouce interface using the button (Delete Failed Submissions)

Step 4: Submission delete status

Run this script to get a status of the deleted submission: check_submission_delete_status.py

Run the script using the command:

docker compose exec -T \
    -e SUB_IDS=<SUB_ID> \
    django \
    python manage.py shell \
    -c "$(cat .check_submission_delete_status.py)" \
    < .preview.txt \
    | tee status.txt

NOTE: this script saves the output in status.txt and uses the preview.txt generated in step 2

Checklist

  • Code review by me
  • Hand tested by me
  • I'm proud of my work
  • Code review by reviewer
  • Hand tested by reviewer
  • CircleCi tests are passing
  • Ready to merge

- Delete child submissions, scores, logs, zips and files with a submission
- Keep a zip when another submission still uses it
- Soft delete also cleans up child submissions, keeping only the records
- Delete failed submissions now cleans up everything and updates counts
- Failed submissions counter no longer counts child submissions
- Clearer messages before deleting submissions
- Add tests for deleting, soft deleting and deleting failed submissions
@Didayolo
Didayolo force-pushed the submission_delete_cleanup branch from 905bbf3 to 2d8c697 Compare November 19, 2026 13:47
@Didayolo

Copy link
Copy Markdown
Member

When a child submission is deleted without its parent, the parent loses the child’s scores (they're attached to both, see api/views/submissions.py:714), and it is never updated afterwards (has_children, status). The old Submission.delete() did that update.

@Didayolo
Didayolo self-requested a review November 19, 2026 14:04
@Didayolo
Didayolo merged commit 554c38f into develop Nov 19, 2026
3 checks passed
@Didayolo
Didayolo deleted the submission_delete_cleanup branch November 19, 2026 14:58
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

2 participants