Skip to content

feat: soft delete dataset draft - #226

Draft
kairoaraujo wants to merge 3 commits into
4TUResearchData:mainfrom
kairoaraujo:feat/soft-delete-dataset-draft
Draft

feat: soft delete dataset draft#226
kairoaraujo wants to merge 3 commits into
4TUResearchData:mainfrom
kairoaraujo:feat/soft-delete-dataset-draft

Conversation

@kairoaraujo

@kairoaraujo kairoaraujo commented Aug 1, 2026

Copy link
Copy Markdown
Collaborator

Summary

Draft deletion is currently a hard delete: the depositor's "delete" removes every triple of the draft, and it cannot be undone. This change makes draft deletion a soft delete, so the draft is flagged and hidden instead of removed, listed in a new "Deleted" section on /my/datasets, from where the depositor can restore it or permanently delete it behind a typed-title confirmation. The existing hard-delete query is reused unchanged for the permanent path. Uploaded files on S3 are not touched by either path.

Changes

  • src/djehuty/schema/migrations/0002_add_dataset_is_deleted.ttl: new migration declaring the djht:is_deleted and djht:deleted_date predicates. Absence means "not deleted", so existing drafts need no back-fill.
  • src/djehuty/web/resources/sparql_templates/soft_delete_dataset_draft.sparql: new — sets the deleted flag and timestamp, keeps all triples and the container→draft link. Same owner/supervisor authorization filter as the hard delete.
  • src/djehuty/web/resources/sparql_templates/restore_dataset_draft.sparql: new — clears the deleted flag.
  • src/djehuty/web/resources/sparql_templates/datasets.sparql: select/bind is_deleted + deleted_date; add an is_deleted filter (True/False/None → only-deleted / exclude-deleted / no-filter).
  • src/djehuty/web/database.py: datasets() gains an is_deleted param (defaults to False, so every existing caller excludes soft-deleted drafts). New soft_delete_dataset_draft / restore_dataset_draft methods plus a shared cache-invalidation helper. The hard delete_dataset_draft is unchanged.
  • src/djehuty/web/wsgi.py: new /restore and /delete-permanently routes and handlers; the two everyday delete callers now soft-delete; ui_my_data renders a "Deleted" bucket; the new-version-draft guard queries with is_deleted=None so a soft-deleted draft still blocks a second draft on the container.
  • src/djehuty/web/resources/html_templates/depositor/my-data.html: "Deleted" section with Restore / Delete-permanently actions.
  • src/djehuty/web/resources/html_templates/depositor/delete-dataset-permanently.html: new — typed-title confirmation page for permanent deletion.
  • tests/e2e/tests/test_soft_delete.py: new — soft-delete moves a draft to Deleted, restore returns it to Drafts, permanent delete is title-gated, and restore access-control.
  • tests/e2e/tests/test_versioning.py: regression test — a soft-deleted draft blocks creating a second new-version draft.
  • tests/unit/test_migrate.py: isolate runner_real to a copy containing only 0001_initial.ttl, so the initial-seed assertions stay stable as real migrations accumulate.
  • docs/knowledge-graph.md: new Soft-deleted drafts subsection under Datasets.
  • doc/knowledge-graph.tex: new Soft-deleted drafts subsection under Datasets.

Approval Checklist

  • I agree to follow Djehuty's code of conduct.
  • I have read and I have follow the code contribution workflow.
  • Code style and conventions were respected.
  • Documentation has been updated where needed (README, docs, or examples).
  • Review approved by at least one maintainer.
  • Merge readiness (PR is squashed into a single commit and follows the commit template).

Issue Reference (optional - PRs may not be associated with an issue)

Screenshots (optional)

Screenshot 2026-08-03 at 08 52 02 Screenshot 2026-08-03 at 08 52 29 Screenshot 2026-08-03 at 08 52 57

Notes (optional)

Additional context, caveats, or follow-up tasks.

@kairoaraujo
kairoaraujo force-pushed the feat/soft-delete-dataset-draft branch from c84b8da to ef8388b Compare August 3, 2026 06:40
allows users to recovery from delete mistaken

- schema/migrations/0002_add_dataset_is_deleted.ttl: declares djht:is_deleted and djht:deleted_date predicates.
- sparql_templates/soft_delete_dataset_draft.sparql: sets the deleted flag + timestamp, keeps all triples.
- sparql_templates/restore_dataset_draft.sparql: clears the deleted flag.
- sparql_templates/datasets.sparql: selects/binds is_deleted + deleted_date, adds the is_deleted filter.
- web/database.py:datasets() gains is_deleted aset_draft / restore_dataset_draft methods +shared cache-invalidation helper. Hard delete_dataset_draft untouched.
- web/wsgi.py: routes + handlers for restore anlete; the two everyday delete callers nowsoft-delete; ui_my_data gains a "Deleted" bucket; new-version guard uses is_deleted=None to block on soft-deleted drafts too.
- html_templates/depositor/my-data.html: "Deleted" section with Restore / Delete-permanently.
- html_templates/depositor/delete-dataset-permanitle: confirmation page.

Signed-off-by: Kairo de Araujo <kairo@dearaujo.nl>

Signed-off-by: Kairo de Araujo <kairo@dearaujo.nl>

Signed-off-by: Kairo de Araujo <kairo@dearaujo.nl>
@kairoaraujo
kairoaraujo force-pushed the feat/soft-delete-dataset-draft branch from ef8388b to f6039b8 Compare August 3, 2026 07:57
Signed-off-by: Kairo de Araujo <kairo@dearaujo.nl>
Signed-off-by: Kairo de Araujo <kairo@dearaujo.nl>
@kairoaraujo
kairoaraujo force-pushed the feat/soft-delete-dataset-draft branch from f6039b8 to 2e80b43 Compare August 3, 2026 09:52
@codecov

codecov Bot commented Aug 3, 2026

Copy link
Copy Markdown

Codecov Report

❌ Patch coverage is 7.69231% with 60 lines in your changes missing coverage. Please review.
✅ Project coverage is 17.22%. Comparing base (9ef6c31) to head (2e80b43).

Files with missing lines Patch % Lines
src/djehuty/web/wsgi.py 4.54% 42 Missing ⚠️
src/djehuty/web/database.py 14.28% 18 Missing ⚠️
Additional details and impacted files
@@            Coverage Diff             @@
##             main     #226      +/-   ##
==========================================
- Coverage   17.28%   17.22%   -0.06%     
==========================================
  Files          21       21              
  Lines       10414    10477      +63     
  Branches     2022     2035      +13     
==========================================
+ Hits         1800     1805       +5     
- Misses       8425     8483      +58     
  Partials      189      189              

☔ View full report in Codecov by Harness.
📢 Have feedback on the report? Share it here.

🚀 New features to boost your workflow:
  • ❄️ Test Analytics: Detect flaky tests, report on failures, and find test suite problems.
  • 📦 JS Bundle Analysis: Save yourself from yourself by tracking and limiting bundle sizes in JS merges.

@kairoaraujo

Copy link
Copy Markdown
Collaborator Author

Follow up on this PR:

  • Remove the DELETE button from inside the form

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant