Add API route for getting an biblio GET /api/v1/biblios/{biblionumber} Gets one Biblio
Created attachment 53823 [details] [review] Bug 17007: REST API: add route to get biblio This patch adds route to get one biblio from koha.biblios table. On top of this biblio there is added key "items" with value being array of items belonging to the requested biblio. To test: 1. Open a browser tab on Koha staff and log in (to create CGISESSID cookie). 2. Send GET request to http://yourlibrary/api/v1/biblios/YYY where YYY is an existing biblionumber. 3. Make sure the returned data is correct. 4. Run unit tests in t/db_dependent/api/v1/biblios.t
Created attachment 53824 [details] [review] Bug 17007: REST API: add route to get biblio Since there could be performance problems with retrieving all the details from all the items belonging to an biblio, there is now returned only a list of itemnumbers within an "items" key instead of all the item's properties. To obtain specific item's properties, use the provided itemnumber to query REST API for items done by Lari Taskula in bug 16825 To test: 1. Open a browser tab on Koha staff and log in (to create CGISESSID cookie). 2. Send GET request to http://yourlibrary/api/v1/biblios/YYY where YYY is an existing biblionumber. 3. Make sure the returned data is correct. 4. Run unit tests in t/db_dependent/api/v1/biblios.t
Created attachment 53825 [details] [review] Bug 17007: REST API: add route to get biblio
Does this respect records that are hidden in the OPAC? http://manual.koha-community.org/16.05/en/administration.html#OpacHiddenItems
(In reply to Magnus Enger from comment #4) > Does this respect records that are hidden in the OPAC? > http://manual.koha-community.org/16.05/en/administration.html#OpacHiddenItems Good catch! It doesn't respect the OpacHiddenItems syspref. The reason is that Koha::Biblio object class doesn't respect it also. It performs a search in DB given only the biblionumber. I think we should file a new bug for this in order to preserve single responsibility. Btw there are some bugs creating new REST API for items, which should respect the OpacHiddenItems, but again, to preserve the single responsibility statement it should be handled from within the middleware - Koha::Items etc.
(In reply to Jiri Kozlovsky from comment #5) > (In reply to Magnus Enger from comment #4) > > Does this respect records that are hidden in the OPAC? > > http://manual.koha-community.org/16.05/en/administration.html#OpacHiddenItems > I think we should file a new bug for this in order to preserve single > responsibility. After thinking this through, I've came up with the idea, that Koha::Biblio's single responsibility is to just retrieve biblios from the DB. So the solution should probably be in the Koha::REST::V1::Biblios, which this patch creates. After all, even though API is not OPAC & the syspref is described as "Define custom rules to hide specific items from search and view on the OPAC. How to write these rules is documented on the Koha wiki.", I agree with the idea it should be hidden from borrowers, but not from staff. This is why I'm going to implement showing OpacHiddenItems only to staff. Changing the status to In Discussion.
Created attachment 53834 [details] [review] Bug 17007: REST API: add route to get biblio As Magnus Enger pointed out, we should hide all the items defined in the OpacHiddenItems syspref from all but staff. This patch adds this functionality. To test: 1. Open a browser tab on Koha staff and log in (to create CGISESSID cookie). 2. Send GET request to http://yourlibrary/api/v1/biblios/YYY where YYY is an existing biblionumber. 3. Make sure the returned data is correct. 4. Find items which are hidden in OPAC with OpacHiddenItems syspref, note their record's biblionumber and repeat point 2 with it. 5. Check that if you are logged in as staff, you see all the items (even those hidden from OPAC) 6. Check that if you are not logged in as staff, you see only the items which are not hidden from OPAC 7. Run unit tests in t/db_dependent/api/v1/biblios.t
Created attachment 53836 [details] [review] Bug 17007: REST API: add route to get biblio Fixed error when user is not staff
Created attachment 54187 [details] [review] Bug 17007: REST API: add route to get biblio This patch adds route to get one biblio from koha.biblios table. On top of this biblio there is added key "items" with value being array of items belonging to the requested biblio. As Magnus Enger pointed out, we should hide all the items defined in the OpacHiddenItems syspref from all but staff. This patch adds this functionality. To test: 1. Open a browser tab on Koha staff and log in (to create CGISESSID cookie). 2. Send GET request to http://yourlibrary/api/v1/biblios/YYY where YYY is an existing biblionumber. 3. Make sure the returned data is correct. 4. Find items which are hidden in OPAC with OpacHiddenItems syspref, note their record's biblionumber and repeat point 2 with it. 5. Check that if you are logged in as staff, you see all the items (even those hidden from OPAC) 6. Check that if you are not logged in as staff, you see only the items which are not hidden from OPAC 7. Run unit tests in t/db_dependent/api/v1/biblios.t Signed-off-by: Lari Taskula <larit@student.uef.fi>
(In reply to Jiri Kozlovsky from comment #7) > Created attachment 53834 [details] [review] [review] This patch removed commit message from the patch. I added it back from your comment field and merged it together with the original description. Hope it's ok now?
Created attachment 54193 [details] [review] Bug 17007: Fix typo in biblio's Swagger definition By running the test introduced in Bug 17032, we can easily catch issues related to object definitions in Swagger vs. Koha-object's columns. This patch fixes a property typo in biblio.json
There has been some progress on getting Biblios in bug 17371, which is CRUD and it seems like this bug is subset of 17371, so we could eventually check that problems we have solved here were applied to 17371 and close this one as duplicate?
bug 17371 is CRUD for biblios, thus it enables GET, POST & PUT - so after I've moved the OpacHiddenItems there, I'm closing this bug as duplicate *** This bug has been marked as a duplicate of bug 17371 ***