Add button to delete work and all editions
Currently, it's only possible to delete an edition via the edit UI:
Proposal & Constraints
We should update this to have a (super-librarian-only) button to delete a work and all of its editions:
Note: it should show a confirmation dialog warning that the work and all of its editions will be deleted. ~If N > 1000, it should say the operation is not possible (due to #5949 )~
Context
Today, when you click "edit" on a book page, you are brought to the edit UI and are given the option to select either the work or the edition. Thers is a button in both cases that says, "Delete Record". My understanding is this button will delete the edition and not the work. The goal is to edit the code so that there is a Delete Work button (that requires a confirmation via a js native dialogue popup). If you click Delete Work, a POST would be made such that the backend will check if you are a super librarian, then batch the work's editions in batches of 1000 and delete them and add a commit message like, "deleting work and its editions, batch 1"
It shouldn't take much code as the edit UI is already wired together. Propose what files (html and backend) would need to change
Work delete functionality should already should exist here: https://github.com/internetarchive/openlibrary/blob/master/openlibrary/templates/books/edit/edition.html. We want update this to allow batching (i.e. delete all editions, not just 1000)
Additional context
Stakeholders
@jimman2003
I think this is what we might want to do:
- Make the
<form>containing the delete all button have aonsubmit="return confirm('Delete work and all of its editions?')"attribute - Always specify
?bulk=true, but: - Make the endpoint error if bulk=true is set + 1000+ editions and the user is not a super-librarian
I'll work on this!
Assignees removed automatically after 14 days.
@cdrini assign me this issue
@aakwei want to try this one? see also the draft copilot worked on :) #11367
Yep! I can work on this :)
Sorry, the last PR was not meant for this here, it was meant for my repo