openlibrary icon indicating copy to clipboard operation
openlibrary copied to clipboard

Limit editing the Internet Archive ID (`ocaid`) to super-librarians and admins

Open seabelis opened this issue 2 months ago • 3 comments

The edit-edition form lets anyone who is a librarian or higher edit the ocaid field (openlibrary/templates/books/edit/edition.html:7 passes is_librarian_or_higher() to openlibrary/components/IdentifiersInput.vue). The server only lets super-librarians and admins change an existing ocaid (_prevent_ocaid_deletion in openlibrary/plugins/upstream/addbook.py checks is_super_librarian_or_higher()). Librarians are a separate group from super-librarians, so:

  • Librarians see an editable field, but saving a change fails with "Changing Internet Archive ID is not allowed."
  • Librarians (and possibly any logged-in user through the server) can add an ocaid to an edition that has none.

Proposed

  • In edition.html, pass is_super_librarian_or_higher() for the IdentifiersInput admin flag so only super-librarians and admins can edit the field.
  • Extend _prevent_ocaid_deletion so users who aren't super-librarians or admins can't add an ocaid either, not just change or remove one.
  • Change the tooltip in IdentifiersInput.vue from "Only librarians can edit this identifier" to "Only admins and super-librarians can edit this identifier."

seabelis avatar Sep 29 '26 15:09 seabelis

Hey, I'd like to pick this up if it's still open.

I looked at _prevent_ocaid_deletion and it only bails out when the edition already has an ocaid, so adding a new one goes through for anyone. I'd switch the template to is_super_librarian_or_higher(), block the add case on the server too, and update the tooltip. Should the server check also cover non-librarian logged in users, or is that handled somewhere else already?

NachiketPatil26 avatar Oct 01 '26 04:10 NachiketPatil26

Just checking in on this one. Happy to start on it if it's still wanted.

NachiketPatil26 avatar Oct 07 '26 23:10 NachiketPatil26

We want only admins to be able to edit ocaid field on editions

mekarpeles avatar Oct 14 '26 15:10 mekarpeles