Bugzilla – Attachment 48169 Details for
Bug 15839
Move the reviews related code to Koha::Reviews
Home
|
New
|
Browse
|
Search
|
[?]
|
Reports
|
Help
|
New Account
|
Log In
[x]
|
Forgot Password
Login:
[x]
[patch]
Bug 15839: Koha::Reviews - Remove approvereview & unapprovereview
Bug-15839-KohaReviews---Remove-approvereview--unap.patch (text/plain), 4.64 KB, created by
Jonathan Druart
on 2016-02-17 13:45:31 UTC
(
hide
)
Description:
Bug 15839: Koha::Reviews - Remove approvereview & unapprovereview
Filename:
MIME Type:
Creator:
Jonathan Druart
Created:
2016-02-17 13:45:31 UTC
Size:
4.64 KB
patch
obsolete
>From 3a108d83002bdb1c63796c5296fa7adc15d3460e Mon Sep 17 00:00:00 2001 >From: Jonathan Druart <jonathan.druart@bugs.koha-community.org> >Date: Tue, 16 Feb 2016 16:06:27 +0000 >Subject: [PATCH] Bug 15839: Koha::Reviews - Remove approvereview & > unapprovereview > >This patch adds 2 new methods to Koha::Review: approve and unapprove. >--- > C4/Review.pm | 38 +------------------------------------- > Koha/Review.pm | 26 ++++++++++++++++++++++++++ > reviews/reviewswaiting.pl | 6 ++++-- > t/db_dependent/Koha/Reviews.t | 9 ++++++++- > 4 files changed, 39 insertions(+), 40 deletions(-) > >diff --git a/C4/Review.pm b/C4/Review.pm >index 5e90008..13a15c7 100644 >--- a/C4/Review.pm >+++ b/C4/Review.pm >@@ -30,7 +30,7 @@ BEGIN { > require Exporter; > @ISA = qw(Exporter); > @EXPORT = qw(getreview savereview updatereview numberofreviews numberofreviewsbybiblionumber >- approvereview unapprovereview deletereview); >+ deletereview); > } > > =head1 NAME >@@ -140,42 +140,6 @@ sub numberofreviewsbybiblionumber { > return $sth->fetchrow; > } > >-=head2 approvereview >- >- approvereview($reviewid); >- >-Takes a reviewid and marks that review approved >- >-=cut >- >-sub approvereview { >- my ($reviewid) = @_; >- my $dbh = C4::Context->dbh(); >- my $query = "UPDATE reviews >- SET approved=? >- WHERE reviewid=?"; >- my $sth = $dbh->prepare($query); >- $sth->execute( 1, $reviewid ); >-} >- >-=head2 unapprovereview >- >- unapprovereview($reviewid); >- >-Takes a reviewid and marks that review as not approved >- >-=cut >- >-sub unapprovereview { >- my ($reviewid) = @_; >- my $dbh = C4::Context->dbh(); >- my $query = "UPDATE reviews >- SET approved=? >- WHERE reviewid=?"; >- my $sth = $dbh->prepare($query); >- $sth->execute( 0, $reviewid ); >-} >- > =head2 deletereview > > deletereview($reviewid); >diff --git a/Koha/Review.pm b/Koha/Review.pm >index 082f71f..72e3e2f 100644 >--- a/Koha/Review.pm >+++ b/Koha/Review.pm >@@ -33,6 +33,32 @@ Koha::Review - Koha Review Object class > > =cut > >+=head3 approve >+ >+ $review->approve >+ >+Approve a review >+ >+=cut >+ >+sub approve { >+ my ( $self ) = @_; >+ $self->approved(1)->store; >+} >+ >+=head3 unapprove >+ >+ $review->unapprove >+ >+Unapprove a review >+ >+=cut >+ >+sub unapprove { >+ my ( $self ) = @_; >+ $self->approved(0)->store; >+} >+ > =head3 type > > =cut >diff --git a/reviews/reviewswaiting.pl b/reviews/reviewswaiting.pl >index b534391..b1b8234 100755 >--- a/reviews/reviewswaiting.pl >+++ b/reviews/reviewswaiting.pl >@@ -46,10 +46,12 @@ my $count = C4::Context->preference('numSearchResults') || 20; > my $total = numberofreviews($status); > > if ( $op eq 'approve' ) { >- approvereview($reviewid); >+ my $review = Koha::Reviews->find( $reviewid ); >+ $review->approve if $review; > } > elsif ( $op eq 'unapprove' ) { >- unapprovereview($reviewid); >+ my $review = Koha::Reviews->find( $reviewid ); >+ $review->unapprove if $review; > } > elsif ( $op eq 'delete' ) { > deletereview($reviewid); >diff --git a/t/db_dependent/Koha/Reviews.t b/t/db_dependent/Koha/Reviews.t >index 321a536..da164f7 100644 >--- a/t/db_dependent/Koha/Reviews.t >+++ b/t/db_dependent/Koha/Reviews.t >@@ -19,7 +19,7 @@ > > use Modern::Perl; > >-use Test::More tests => 4; >+use Test::More tests => 7; > > use Koha::Review; > use Koha::Reviews; >@@ -36,6 +36,7 @@ my $patron_2 = $builder->build({ source => 'Borrower' }); > my $biblio_1 = $builder->build({ source => 'Biblio' }); > my $biblio_2 = $builder->build({ source => 'Biblio' }); > my $nb_of_reviews = Koha::Reviews->search->count; >+my $nb_of_approved_reviews = Koha::Reviews->search({ approved => 1 })->count; > my $new_review_1_1 = Koha::Review->new({ > borrowernumber => $patron_1->{borrowernumber}, > biblionumber => $biblio_1->{biblionumber}, >@@ -55,6 +56,12 @@ my $new_review_2_1 = Koha::Review->new({ > like( $new_review_1_1->reviewid, qr|^\d+$|, 'Adding a new review should have set the reviewid'); > is( Koha::Reviews->search->count, $nb_of_reviews + 3, 'The 3 reviews should have been added' ); > >+is( Koha::Reviews->search({approved => 1})->count, $nb_of_approved_reviews, 'There should not be new approved reviews' ); >+$new_review_1_1->approve; >+is( Koha::Reviews->search({approved => 1})->count, $nb_of_approved_reviews + 1, 'There should be 1 new approved review' ); >+$new_review_1_1->unapprove; >+is( Koha::Reviews->search({approved => 1})->count, $nb_of_approved_reviews, 'There should not be any new approved review anymore' ); >+ > my $retrieved_review_1_1 = Koha::Reviews->find( $new_review_1_1->reviewid ); > is( $retrieved_review_1_1->review, $new_review_1_1->review, 'Find a review by id should return the correct review' ); > >-- >2.7.0
You cannot view the attachment while viewing its details because your browser does not support IFRAMEs.
View the attachment on a separate page
.
View Attachment As Diff
View Attachment As Raw
Actions:
View
|
Diff
|
Splinter Review
Attachments on
bug 15839
:
48166
|
48167
|
48168
|
48169
|
48170
|
48171
|
48172
|
48173
|
48174
|
48175
|
48176
|
48280
|
48281
|
48282
|
48283
|
48284
|
48285
|
48286
|
48287
|
48288
|
48289
|
48290
|
51197
|
51198
|
51199
|
51200
|
51201
|
51202
|
51203
|
51204
|
51205
|
51206
|
51207
|
53794
|
53795
|
53796
|
53797
|
53798
|
53799
|
53800
|
53801
|
53802
|
53803
|
53804
|
53805
|
53806
|
53807