@@ -, +, @@ article_requests_current ->article_requests->filter_by_current. $ kshell k$ prove t/db_dependent/Koha/Biblio.t --- Koha/Biblio.pm | 28 ------ .../prog/en/modules/circ/request-article.tt | 6 +- t/db_dependent/Koha/Biblio.t | 88 +------------------ 3 files changed, 5 insertions(+), 117 deletions(-) --- a/Koha/Biblio.pm +++ a/Koha/Biblio.pm @@ -354,34 +354,6 @@ sub article_requests { return Koha::ArticleRequests->_new_from_dbic( scalar $self->_result->article_requests ); } -=head3 article_requests_current - - my $current_article_requests = $biblio->article_requests_current - -Returns the article requests associated with this biblio that are incomplete - -=cut - -sub article_requests_current { - my ( $self ) = @_; - - return $self->article_requests->filter_by_current; -} - -=head3 article_requests_finished - - my $finished_article_requests = $biblio->article_requests_finished - -Returns the article requests associated with this biblio that are completed - -=cut - -sub article_requests_finished { - my ( $self, $borrower ) = @_; - - return $self->article_requests->filter_by_finished; -} - =head3 items my $items = $biblio->items(); --- a/koha-tmpl/intranet-tmpl/prog/en/modules/circ/request-article.tt +++ a/koha-tmpl/intranet-tmpl/prog/en/modules/circ/request-article.tt @@ -1,5 +1,6 @@ [% USE raw %] [% USE Asset %] +[% USE Context %] [% USE KohaDates %] [% USE Branches %] [% USE ItemTypes %] @@ -284,7 +285,8 @@ [% END %] - [% IF biblio.article_requests_current && !patron %] + [% SET biblio_current_article_requests = Context.Scalar( Context.Scalar( biblio, 'article_requests' ), 'filter_by_current' ) %] + [% IF biblio_current_article_requests.count > 0 && !patron %]
Current article requests @@ -307,7 +309,7 @@   - [% FOREACH ar IN biblio.article_requests_current %] + [% FOREACH ar IN biblio_current_article_requests %] [% ar.created_on | $KohaDates %] [% ar.borrower.firstname | html %] [% ar.borrower.surname | html %] --- a/t/db_dependent/Koha/Biblio.t +++ a/t/db_dependent/Koha/Biblio.t @@ -17,7 +17,7 @@ use Modern::Perl; -use Test::More tests => 18; +use Test::More tests => 16; use C4::Biblio qw( AddBiblio ModBiblio ); use Koha::Database; @@ -724,89 +724,3 @@ subtest 'article_requests() tests' => sub { $schema->storage->txn_rollback; }; - -subtest 'article_requests_current() tests' => sub { - - plan tests => 7; - - $schema->storage->txn_begin; - - my $patron = $builder->build_object( { class => 'Koha::Patrons' } ); - my $item = $builder->build_sample_item; - my $biblio = $item->biblio; - - my $article_request = Koha::ArticleRequest->new( - { - borrowernumber => $patron->id, - biblionumber => $biblio->id, - itemnumber => $item->id, - title => $biblio->title, - } - )->request(); - - my $ar = $biblio->article_requests(); - is( ref($ar), 'Koha::ArticleRequests', - '$biblio->article_requests returns Koha::ArticleRequests object' ); - is( $ar->next->id, $article_request->id, - 'Returned article request matches' ); - - is( $biblio->article_requests_current()->count(), - 1, 'Open request returned for article_requests_current' ); - $article_request->set_pending(); - is( $biblio->article_requests_current()->count(), - 1, 'Pending request returned for article_requests_current' ); - $article_request->process(); - is( $biblio->article_requests_current()->count(), - 1, 'Processing request returned for article_requests_current' ); - $article_request->complete(); - is( $biblio->article_requests_current()->count(), - 0, 'Completed request not returned for article_requests_current' ); - $article_request->cancel(); - is( $biblio->article_requests_current()->count(), - 0, 'Canceled request not returned for article_requests_current' ); - - $schema->storage->txn_rollback; -}; - -subtest 'article_requests_finished() tests' => sub { - - plan tests => 7; - - $schema->storage->txn_begin; - - my $patron = $builder->build_object( { class => 'Koha::Patrons' } ); - my $item = $builder->build_sample_item; - my $biblio = $item->biblio; - - my $article_request = Koha::ArticleRequest->new( - { - borrowernumber => $patron->id, - biblionumber => $biblio->id, - itemnumber => $item->id, - title => $biblio->title, - } - )->request(); - - my $ar = $biblio->article_requests(); - is( ref($ar), 'Koha::ArticleRequests', - '$biblio->article_requests returns Koha::ArticleRequests object' ); - is( $ar->next->id, $article_request->id, - 'Returned article request matches' ); - - is( $biblio->article_requests_finished->count, - 0, 'Open request returned for article_requests_finished' ); - $article_request->set_pending(); - is( $biblio->article_requests_finished->count, - 0, 'Pending request returned for article_requests_finished' ); - $article_request->process(); - is( $biblio->article_requests_finished->count, - 0, 'Processing request returned for article_requests_finished' ); - $article_request->complete(); - is( $biblio->article_requests_finished->count, - 1, 'Completed request returned for article_requests_finished' ); - $article_request->cancel(); - is( $biblio->article_requests_finished->count, - 1, 'Cancelled request not returned for article_requests_finished' ); - - $schema->storage->txn_rollback; -}; --