internetarchive / internetarchive/openlibrary

Add button to delete work and all editions

Open
#7,973 7 comments 0 reactions 0 assignees View on GitHub
Affects: Librarians Lead: @cdrini Priority: 2 Theme: Editing Type: Feature Request
Dominant language
Python
Stars
6.7k
Forks
2k
Avg merge
2d 19h
Merged PRs (30d)
138

Description

Currently, it's only possible to delete an edition via the edit UI:

![image](https://github.com/internetarchive/openlibrary/assets/6251786/506a7ff3-371c-4577-a64f-b52f31bd1b87)

### Proposal & Constraints

We should update this to have a (super-librarian-only) button to delete a work and all of its editions:

![image](https://github.com/internetarchive/openlibrary/assets/6251786/2f0b9407-ce42-49a9-a3c8-82d91143678d)

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

Contributor guide

Open the contributing guide

Assessment

This issue has not been assessed yet.

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.