Bug 29939

Summary: Replace opac-ratings-ajax.pl with a new REST API route
Product: Koha Reporter: Marcel de Rooy <m.de.rooy>
Component: Architecture, internals, and plumbingAssignee: Jonathan Druart <jonathan.druart>
Status: CLOSED FIXED QA Contact: Testopia <testopia>
Severity: enhancement    
Priority: P5 - low CC: fridolin.somers, jonathan.druart, lucas
Version: Main   
Hardware: All   
OS: All   
Change sponsored?: --- Patch complexity: Small patch
Documentation contact: Documentation submission:
Text to go in the release notes:
Version(s) released in:
22.11.00
Attachments: Bug 29939: Use the REST API for ratings
Bug 29939: Use the REST API for ratings
Bug 29939: Use the REST API for ratings

Description Marcel de Rooy 2022-01-25 12:20:31 UTC
This script certainly needs a better authentication check but it is less trivial than the others.
The block with Koha::Ratings calls should be within a check on loggedinuser.
The whole script is a weird mix between an ajax script and a regular one.

This statement will crash on an undefined borrowernumber (SQL constraint):
  Koha::Rating->new( { biblionumber => $biblionumber, borrowernumber => $loggedinuser, rating_value => $rating_value, })->store;
Comment 1 Fridolin Somers 2022-01-26 08:14:26 UTC
Do we know if this feature is even used ?
Looks like a very old pre-social-network feature.
In HEA we see preference is enabled, but it is by default.
Comment 2 Katrin Fischer 2022-01-26 08:17:31 UTC
If I am correct that these are the star ratings, there has been additions in the last versions to it which I think shows it must be used.
Comment 3 Jonathan Druart 2022-08-16 10:20:53 UTC
Created attachment 139171 [details] [review]
Bug 29939: Use the REST API for ratings

This patch replaces opac-ratings-ajax.pl with a new REST API route
POST /public/biblios/42/ratings

Note that we could go further and refactor the 'start_rating' select
code.

Test plan:
Test the "star ratings" feature at the OPAC, on the different page where
it's displayed.
Comment 4 Jonathan Druart 2022-08-16 10:21:56 UTC
Stealing this bug, but you may consider it needs its own bug. Let me know and I will move the patch somewhere else.
Comment 5 Owen Leonard 2022-08-18 18:27:03 UTC
Created attachment 139412 [details] [review]
Bug 29939: Use the REST API for ratings

This patch replaces opac-ratings-ajax.pl with a new REST API route
POST /public/biblios/42/ratings

Note that we could go further and refactor the 'start_rating' select
code.

Test plan:
Test the "star ratings" feature at the OPAC, on the different page
where it's displayed.

Signed-off-by: Owen Leonard <oleonard@myacpl.org>
Comment 6 Katrin Fischer 2022-08-21 21:21:50 UTC
Created attachment 139559 [details] [review]
Bug 29939: Use the REST API for ratings

This patch replaces opac-ratings-ajax.pl with a new REST API route
POST /public/biblios/42/ratings

Note that we could go further and refactor the 'start_rating' select
code.

Test plan:
Test the "star ratings" feature at the OPAC, on the different page
where it's displayed.

Signed-off-by: Owen Leonard <oleonard@myacpl.org>

Signed-off-by: Katrin Fischer <katrin.fischer.83@web.de>
Comment 7 Tomás Cohen Arazi 2022-08-22 14:46:17 UTC
Pushed to master for 22.11.

Nice work everyone, thanks!
Comment 8 Lucas Gass 2022-10-14 19:47:35 UTC
Enhancement will not be in 22.05.x