Bugzilla – Attachment 125838 Details for
Bug 29083
Update article requests-related Koha::Patron methods to use relationships
Home
|
New
|
Browse
|
Search
|
[?]
|
Reports
|
Help
|
New Account
|
Log In
[x]
|
Forgot Password
Login:
[x]
[patch]
Bug 29083: Remove article_requests_finished and article_requests_current
Bug-29083-Remove-articlerequestsfinished-and-artic.patch (text/plain), 9.23 KB, created by
Tomás Cohen Arazi (tcohen)
on 2021-10-06 16:19:19 UTC
(
hide
)
Description:
Bug 29083: Remove article_requests_finished and article_requests_current
Filename:
MIME Type:
Creator:
Tomás Cohen Arazi (tcohen)
Created:
2021-10-06 16:19:19 UTC
Size:
9.23 KB
patch
obsolete
>From 86b9af61b83b180b2b89e70ffa0f51de35e38ee6 Mon Sep 17 00:00:00 2001 >From: Tomas Cohen Arazi <tomascohen@theke.io> >Date: Wed, 6 Oct 2021 13:05:07 -0300 >Subject: [PATCH] Bug 29083: Remove article_requests_finished and > article_requests_current > >This patch removes those methods that are not really needed. Templates >are adjusted to use the expected combination of >->article_requests->filter_by_current. > >To test: >1. Apply this patch >2. Visit a patron with article requests >=> SUCCESS: All works >3. Run: > $ kshell > k$ prove t/db_dependent/Koha/Patron.t >=> SUCCESS: Tests pass, less tests. >4. Sign off :-D > >Signed-off-by: Tomas Cohen Arazi <tomascohen@theke.io> >--- > Koha/Patron.pm | 28 ------ > .../en/includes/patron-article-requests.inc | 6 +- > .../prog/en/modules/members/moremember.tt | 4 +- > .../bootstrap/en/modules/opac-user.tt | 2 +- > opac/opac-user.pl | 2 +- > t/db_dependent/Koha/Patron.t | 86 +------------------ > 6 files changed, 10 insertions(+), 118 deletions(-) > >diff --git a/Koha/Patron.pm b/Koha/Patron.pm >index ec64d00370..9fd93e8c44 100644 >--- a/Koha/Patron.pm >+++ b/Koha/Patron.pm >@@ -1015,34 +1015,6 @@ sub article_requests { > return Koha::ArticleRequests->_new_from_dbic( scalar $self->_result->article_requests ); > } > >-=head3 article_requests_current >- >- my $current_article_requests = $patron->article_requests_current >- >-Returns the article requests associated with this patron 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 patron that are completed >- >-=cut >- >-sub article_requests_finished { >- my ( $self ) = @_; >- >- return $self->article_requests->filter_by_finished; >-} >- > =head3 add_enrolment_fee_if_needed > > my $enrolment_fee = $patron->add_enrolment_fee_if_needed($renewal); >diff --git a/koha-tmpl/intranet-tmpl/prog/en/includes/patron-article-requests.inc b/koha-tmpl/intranet-tmpl/prog/en/includes/patron-article-requests.inc >index b2a25a0580..a22325e785 100644 >--- a/koha-tmpl/intranet-tmpl/prog/en/includes/patron-article-requests.inc >+++ b/koha-tmpl/intranet-tmpl/prog/en/includes/patron-article-requests.inc >@@ -1,5 +1,7 @@ >+[% USE Context %] >+[% SET current_article_requests = Context.Scalar( Context.Scalar( patron, 'article_requests' ), 'filter_by_current' ) %] > <div id="article-requests"> >-[% IF patron.article_requests_current.count %] >+[% IF current_article_requests.count > 0 %] > <table id="article-requests-table" class="table table-bordered table-striped"> > <thead> > <tr> >@@ -20,7 +22,7 @@ > </thead> > > <tbody> >- [% FOREACH ar IN patron.article_requests_current %] >+ [% FOREACH ar IN current_article_requests %] > <tr> > <td class="article-request-record-title"> > <a class="article-request-title" href="/cgi-bin/koha/circ/request-article.pl?biblionumber=[% ar.biblionumber | html %]"> >diff --git a/koha-tmpl/intranet-tmpl/prog/en/modules/members/moremember.tt b/koha-tmpl/intranet-tmpl/prog/en/modules/members/moremember.tt >index 300d642bea..55c4d8e740 100644 >--- a/koha-tmpl/intranet-tmpl/prog/en/modules/members/moremember.tt >+++ b/koha-tmpl/intranet-tmpl/prog/en/modules/members/moremember.tt >@@ -1,5 +1,6 @@ > [% USE raw %] > [% USE Asset %] >+[% USE Context %] > [% USE Koha %] > [% USE Branches %] > [% USE ItemTypes %] >@@ -695,8 +696,9 @@ > </li> > [% END %] > [% IF Koha.Preference('ArticleRequests') %] >+ [% SET article_requests = Context.Scalar( Context.Scalar( patron, 'article_requests' ), 'filter_by_current') %] > <li> >- <a href="#article-requests" id="article-requests-tab"> [% patron.article_requests_current.count | html %] Article requests</a> >+ <a href="#article-requests" id="article-requests-tab"> [% article_requests.count | html %] Article requests</a> > </li> > [% END %] > >diff --git a/koha-tmpl/opac-tmpl/bootstrap/en/modules/opac-user.tt b/koha-tmpl/opac-tmpl/bootstrap/en/modules/opac-user.tt >index ece7aee244..dac477d909 100644 >--- a/koha-tmpl/opac-tmpl/bootstrap/en/modules/opac-user.tt >+++ b/koha-tmpl/opac-tmpl/bootstrap/en/modules/opac-user.tt >@@ -866,7 +866,7 @@ > <caption class="sr-only">Article requests</caption> > <tr><td>You have no article requests currently.</td></tr> > </table> >- [% END # IF article_requests_current.count %] >+ [% END # IF current_article_requests_count %] > </div> <!-- / #opac-user-article-requests --> > [% END %] > >diff --git a/opac/opac-user.pl b/opac/opac-user.pl >index 1cd97b628e..0515b162a3 100755 >--- a/opac/opac-user.pl >+++ b/opac/opac-user.pl >@@ -387,7 +387,7 @@ if ( C4::Context->preference('AllowPatronToSetFinesVisibilityForGuarantor') > } > > if ( C4::Context->preference("ArticleRequests") ) { >- my @current_article_requests = $patron->article_requests_current->as_list; >+ my @current_article_requests = $patron->article_requests->filter_by_current->as_list; > $template->param( > current_article_requests => \@current_article_requests, > current_article_requests_count => scalar @current_article_requests, >diff --git a/t/db_dependent/Koha/Patron.t b/t/db_dependent/Koha/Patron.t >index 8142e0c848..2929349661 100755 >--- a/t/db_dependent/Koha/Patron.t >+++ b/t/db_dependent/Koha/Patron.t >@@ -19,7 +19,7 @@ > > use Modern::Perl; > >-use Test::More tests => 12; >+use Test::More tests => 10; > use Test::Exception; > use Test::Warn; > >@@ -846,87 +846,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 $article_request = Koha::ArticleRequest->new( >- { >- borrowernumber => $patron->id, >- biblionumber => $item->biblionumber, >- itemnumber => $item->itemnumber, >- title => "Boo", >- } >- )->request(); >- >- my $ar = $patron->article_requests(); >- is( ref($ar), 'Koha::ArticleRequests', >- '$patron->article_requests returns Koha::ArticleRequests object' ); >- is( $ar->next->id, $article_request->id, >- 'Returned article request matches' ); >- >- is( $patron->article_requests_current()->count(), >- 1, 'Open request returned for article_requests_current' ); >- $article_request->set_pending(); >- is( $patron->article_requests_current()->count(), >- 1, 'Pending request returned for article_requests_current' ); >- $article_request->process(); >- is( $patron->article_requests_current()->count(), >- 1, 'Processing request returned for article_requests_current' ); >- $article_request->complete(); >- is( $patron->article_requests_current()->count(), >- 0, 'Completed request not returned for article_requests_current' ); >- $article_request->cancel(); >- is( $patron->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 $article_request = Koha::ArticleRequest->new( >- { >- borrowernumber => $patron->id, >- biblionumber => $item->biblionumber, >- itemnumber => $item->itemnumber, >- title => "Boo", >- } >- )->request(); >- >- my $ar = $patron->article_requests(); >- is( ref($ar), 'Koha::ArticleRequests', >- '$patron->article_requests returns Koha::ArticleRequests object' ); >- is( $ar->next->id, $article_request->id, >- 'Returned article request matches' ); >- >- is( $patron->article_requests_finished->count, >- 0, 'Open request returned for article_requests_finished' ); >- $article_request->set_pending(); >- is( $patron->article_requests_finished->count, >- 0, 'Pending request returned for article_requests_finished' ); >- $article_request->process(); >- is( $patron->article_requests_finished->count, >- 0, 'Processing request returned for article_requests_finished' ); >- $article_request->complete(); >- is( $patron->article_requests_finished->count, >- 1, 'Completed request returned for article_requests_finished' ); >- $article_request->cancel(); >- is( $patron->article_requests_finished->count, >- 1, 'Cancelled request not returned for article_requests_finished' ); >- >- $schema->storage->txn_rollback; >-}; >-- >2.32.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 29083
:
125160
|
125161
|
125162
|
125186
|
125240
|
125241
|
125242
|
125243
|
125268
|
125269
|
125270
|
125271
|
125640
|
125641
|
125642
|
125643
|
125833
|
125834
|
125835
|
125836
|
125837
|
125838
|
125840
|
125862