From 6f67992ffa893de3f17641f739064f748c200cf8 Mon Sep 17 00:00:00 2001 From: Jonathan Druart Date: Tue, 12 Jul 2016 11:28:57 +0100 Subject: [PATCH] Bug 17089: Koha::Ratings - Remove DelRating Signed-off-by: Owen Leonard Signed-off-by: Marcel de Rooy Signed-off-by: Kyle M Hall --- C4/Ratings.pm | 27 --------------------------- opac/opac-ratings-ajax.pl | 4 ++-- 2 files changed, 2 insertions(+), 29 deletions(-) diff --git a/C4/Ratings.pm b/C4/Ratings.pm index 0ec6e0364e..061d42bcf1 100644 --- a/C4/Ratings.pm +++ b/C4/Ratings.pm @@ -35,7 +35,6 @@ BEGIN { @EXPORT = qw( &GetRating - &DelRating ); } @@ -57,9 +56,6 @@ Get a rating for a bib my $rating_hashref = GetRating( $biblionumber, undef ); my $rating_hashref = GetRating( $biblionumber, $borrowernumber ); -Delete a rating for a bib - my $rating_hashref = DelRating( $biblionumber, $borrowernumber ); - All subroutines in Ratings.pm return a hashref which contain 4 keys @@ -184,28 +180,5 @@ sub GetRating { return \%rating_hash; } -=head2 DelRating - - my $rating_hashref = DelRating( $biblionumber, $borrowernumber ); - -Delete a rating for a bib - -=cut - -sub DelRating { - my ( $biblionumber, $borrowernumber ) = @_; - - my $rating = Koha::Database->new()->schema->resultset('Rating')->find( - { - borrowernumber => $borrowernumber, - biblionumber => $biblionumber - } - ); - - $rating->delete() if $rating; - - return GetRating($biblionumber); -} - 1; __END__ diff --git a/opac/opac-ratings-ajax.pl b/opac/opac-ratings-ajax.pl index 63e2ebc827..a99a335842 100755 --- a/opac/opac-ratings-ajax.pl +++ b/opac/opac-ratings-ajax.pl @@ -73,8 +73,8 @@ my $rating; $rating_value //= ''; if ( $rating_value eq '' ) { -#### delete - $rating = DelRating( $biblionumber, $loggedinuser ); + Koha::Ratings->find( { biblionumber => $biblionumber, borrowernumber => $loggedinuser } )->delete; + $rating = Koha::Ratings->search({ biblionumber => $biblionumber })->get_rating; } elsif ( $rating_value and !$rating_old_value ) { -- 2.39.5