Limit editing the Internet Archive ID (`ocaid`) to super-librarians and admins
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
ocaidto an edition that has none.
Proposed
- In
edition.html, passis_super_librarian_or_higher()for theIdentifiersInputadmin flag so only super-librarians and admins can edit the field. - Extend
_prevent_ocaid_deletionso users who aren't super-librarians or admins can't add anocaideither, not just change or remove one. - Change the tooltip in
IdentifiersInput.vuefrom "Only librarians can edit this identifier" to "Only admins and super-librarians can edit this identifier."
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?
Just checking in on this one. Happy to start on it if it's still wanted.
We want only admins to be able to edit ocaid field on editions