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

--- Comment #1 from Tomás Cohen Arazi (tcohen) <[email protected]> ---
Created attachment 212228
  -->
https://bugs.koha-community.org/bugzilla3/attachment.cgi?id=212228&action=edit
Bug 27184: Allow listing a patron's old checkouts through the API

This patch adds a `checked_in` query parameter to the
GET /patrons/{patron_id}/checkouts route, so the circulation history
can be fetched paginated instead of loaded in full by readingrec.pl.

The patron is now the pivot: it is looked up through
Koha::Patrons->search_limited, like GET /patrons/{patron_id} does, so
patrons the requesting user is not allowed to see (library groups
'Hide patron info', IndependentBranches) return 404. This applies to
both current and old checkouts.

Listing old checkouts also requires:
- the 'intranetreadinghistory' system preference enabled
- the borrowers: view_checkout_history permission

Otherwise a 403 with the `checkout_history_not_allowed` error_code is
returned.

It also adds the `issuer.library` embed. The issuer is a Koha::Patron,
so its information is redacted when the user cannot see it, but
`library_id` is kept. Embedding the library allows the UI to display
'A patron from <library>' instead of leaking the staff member's name.

The first subtest was also missing its txn_rollback, fixed.

Test plan:
1. Apply patch
2. Run:
   $ ktd --shell
  k$ yarn api:bundle
  k$ restart_all
  k$ prove t/db_dependent/api/v1/patrons_checkouts.t \
           t/db_dependent/api/v1/checkouts.t \
           xt/api.t
=> SUCCESS: Tests pass!
3. Sign off :-D

Assisted-by: Opus 5.5 (Anthropic)

-- 
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