https://bugs.koha-community.org/bugzilla3/show_bug.cgi?id=42625

--- Comment #219 from Martin Renvoize (ashimema) 
<[email protected]> ---
Created attachment 211242
  -->
https://bugs.koha-community.org/bugzilla3/attachment.cgi?id=211242&action=edit
Bug 42625: (follow-up) Add a narrow library groups route for record source
editing

The record source form lists the library groups flagged for record source
editing. It used GET /library_groups, which Bug 38291 now 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 got 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 <[email protected]>

-- 
You are receiving this mail because:
You are watching all bug changes.
_______________________________________________
Koha-bugs mailing list -- [email protected]
To unsubscribe send an email to [email protected]
website : http://www.koha-community.org/
git : http://git.koha-community.org/
bugs : http://bugs.koha-community.org/

Reply via email to