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

--- Comment #81 from Martin Renvoize (ashimema) 
<[email protected]> ---
Created attachment 211240
  -->
https://bugs.koha-community.org/bugzilla3/attachment.cgi?id=211240&action=edit
Bug 38291: (QA follow-up) Filter library groups with q only

The endpoint declared a query parameter for every attribute of a library
group, which only repeat what the q parameter does. For the boolean
attributes they were also wrong: they were declared as integers although
the API returns booleans, so filtering with a value read back from the
API, for example ?is_local_hold_group=true, was refused.

Declaring them as booleans would not have been enough. Plain query
parameters are matched with like, and any value that is not empty counts
as true, so ?is_local_hold_group=false (and =0) would list the groups
that have the flag set. Other routes behave the same way, for instance
/patrons?protected=false lists the protected patrons.

/libraries, which this route follows, filters its boolean attributes with
q, and nothing needs the plain parameters here: each one that is
published is a promise to keep supporting it. Remove them, and test
that every attribute that is a flag can be filtered with q, with true
and false.

To test:
1. Apply the patches, then run yarn api:bundle and restart_all
2. Administration > Library groups: create a group "Hold group" with
   "Is local hold group" checked, and a group "Other" without it
3. Log in to the staff interface as a superlibrarian and visit
   /api/v1/library_groups?q={"is_local_hold_group":true}
=> SUCCESS: "Hold group" is listed, and "Other" is not
4. Visit /api/v1/library_groups?q={"is_local_hold_group":false}
=> SUCCESS: "Other" is listed, and "Hold group" is not
5. Visit /api/v1/library_groups?q={"title":"Other"}
=> SUCCESS: only "Other" is listed
6. Run: prove t/db_dependent/api/v1/library_groups.t xt/api.t
=> SUCCESS: Tests pass

Co-Authored-By: Claude Sonnet 5.5 <[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