https://bugs.koha-community.org/bugzilla3/show_bug.cgi?id=44051 --- Comment #1 from Martin Renvoize (ashimema) <martin.renvoize@openfifth.co.uk> --- Created attachment 211263 --> https://bugs.koha-community.org/bugzilla3/attachment.cgi?id=211263&action=edit Bug 44051: Add a narrow library groups route for record source editing The record source form added by Bug 42625 lists the library groups flagged for record source editing. It gets them from GET /library_groups, which Bug 38291 restricts to manage_libraries as it returns the full group configuration, including the policy flags (hide patron info, limit item editing, limit report access). A user allowed to manage record sources but not libraries gets a 403 and an empty selector. Add GET /record_source_editing_groups, authorized by manage_record_sources, which: - only lists the groups flagged for record source editing - only returns library_group_id, title and description - accepts q, _order_by, _match and paging for the fields it returns (library_group_id, title, description) and rejects anything else with invalid_query, however the field is spelled (API or DB name, me. prefix, relationship, nested in -or, request body), so the policy flags cannot be read by filtering or sorting on them The controller keeps the per feature column and allowed fields in one table, so other features that need to pick a library group can add a route with their own permission. The JS LibraryGroupsAPIClient gets a matching table of feature routes, used by the record source selector. To test: 1. Apply the patches, run yarn api:bundle and yarn js:build, restart_all 2. prove t/db_dependent/api/v1/record_source_editing_groups.t t/db_dependent/api/v1/library_groups.t t/db_dependent/api/v1/record_sources.t xt/api.t => SUCCESS: Tests pass 3. Create a staff user without the superlibrarian flag, with only the catalogue permission and Parameters > manage_record_sources 4. Administration > Library groups: create a group with "Use for record source editing" checked and another without 5. As the user from step 3, Administration > Record sources > New record source => SUCCESS: "Editable by library groups" lists only the first group 6. As the same user, in the browser console or with curl, request /api/v1/record_source_editing_groups?_order_by=hide_patron_info and /api/v1/library_groups => SUCCESS: 400 invalid_query, and 403 7. Run the Cypress spec t/cypress/integration/Admin/RecordSources_spec.ts => SUCCESS: Tests pass Signed-off-by: Martin Renvoize <martin.renvoize@openfifth.co.uk> -- You are receiving this mail because: You are the assignee for the bug. You are watching all bug changes.