-
-
Notifications
You must be signed in to change notification settings - Fork 1.2k
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
Added an API for deleting work #5433
Added an API for deleting work #5433
Conversation
… clarifications as well
# Conflicts: # openlibrary/plugins/openlibrary/api.py
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Lgtm! Some small changes
Testing now... |
Tested by running in browser console:
Hmm, how did you test this one? I'm having trouble getting this to run for me. |
Co-authored-by: Drini Cami <cdrini@gmail.com>
Co-authored-by: Drini Cami <cdrini@gmail.com>
Co-authored-by: Drini Cami <cdrini@gmail.com>
yeah, I made the same err a couple of times too 😄 An example would be |
…n and added more type hints
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Ok! This lgtm! A few small readability changes, and then should be good to go :) Testing now...
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
- Logged out
- ❔
await fetch('/works/OL54120W/-/delete', {method: 'POST'})
405s instead of 403s... - ✅
await fetch('/works/OL54120W/-/delete.json', {method: 'POST'})
403s!
- ❔
- Logged in, admin
- ❔
await fetch('/works/OL54120W/-/delete', {method: 'POST'})
405s... - ✅
await fetch('/works/OL54120W/-/delete.json', {method: 'POST'})
Works! Status: ok- ✅ Work deleted
- ✅ Editions deleted
- ✅ Single batch edit made
- ✅ await fetch('/works/OL18319A/-/delete.json', {method: 'POST'}) 405s
- ✅ await fetch('/authors/OL18319A/-/delete.json', {method: 'POST'}) 405s
- ❔
- Logged in, non-admin
- ✅
await fetch('/works/OL61982W/-/delete.json', {method: 'POST'})
403s
- ✅
Ok, no clue why it's not working without .json :/ But I'll take it! Lgtm!
I've proposed an idea to @cdrini that instead of deleting a work from the OL client by doing multiple http calls and getting all the editions, then making a bulk delete call to the server to delete editions of work + work. We can have an endpoint in OL server which can delete a work and all its references. This also allows us to have an option to delete work in the frontend for librarians in the future if that sounds like a good idea.
Technical
Fetches all the editions, deletes all the editions and works together. Can only be hit by admins and librarians.
Stakeholders
@cdrini