Bug 29939 - Replace opac-ratings-ajax.pl with a new REST API route
Summary: Replace opac-ratings-ajax.pl with a new REST API route
Status: CLOSED FIXED
Alias: None
Product: Koha
Classification: Unclassified
Component: Architecture, internals, and plumbing (show other bugs)
Version: master
Hardware: All All
: P5 - low enhancement (vote)
Assignee: Jonathan Druart
QA Contact: Testopia
URL:
Keywords:
Depends on:
Blocks:
 
Reported: 2022-01-25 12:20 UTC by Marcel de Rooy
Modified: 2023-06-08 22:26 UTC (History)
3 users (show)

See Also:
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 (24.81 KB, patch)
2022-08-16 10:20 UTC, Jonathan Druart
Details | Diff | Splinter Review
Bug 29939: Use the REST API for ratings (24.83 KB, patch)
2022-08-18 18:27 UTC, Owen Leonard
Details | Diff | Splinter Review
Bug 29939: Use the REST API for ratings (24.89 KB, patch)
2022-08-21 21:21 UTC, Katrin Fischer
Details | Diff | Splinter Review

Note You need to log in before you can comment on or make changes to this bug.
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