@@ -, +, @@
- "your routing lists" tab is now highlighted when active
- get_routinglists was renamed to get_routing_lists
- Koha::Patron->get_routing_lists returns the ->search result
directly
- Koha::Subscription::RoutingList->subscription uses DBIC
relationship
---
C4/Auth.pm | 1 -
Koha/Patron.pm | 9 ++++-----
Koha/Subscription/Routinglist.pm | 2 +-
koha-tmpl/opac-tmpl/bootstrap/en/includes/usermenu.inc | 2 +-
opac/opac-routing-lists.pl | 4 ++--
t/db_dependent/Koha/Patrons.t | 12 ++++++------
6 files changed, 14 insertions(+), 16 deletions(-)
--- a/C4/Auth.pm
+++ a/C4/Auth.pm
@@ -610,7 +610,6 @@ sub get_template_and_user {
PatronSelfRegistration => C4::Context->preference("PatronSelfRegistration"),
PatronSelfRegistrationDefaultCategory => C4::Context->preference("PatronSelfRegistrationDefaultCategory"),
useDischarge => C4::Context->preference('useDischarge'),
- routing_lists_exist => ( $patron and $patron->get_routinglists ),
);
$template->param( OpacPublic => '1' ) if ( $user || C4::Context->preference("OpacPublic") );
--- a/Koha/Patron.pm
+++ a/Koha/Patron.pm
@@ -589,18 +589,17 @@ sub get_overdues {
);
}
-=head3 get_routinglists
+=head3 get_routing_lists
-my @routinglists = $patron->get_routinglists
+my @routinglists = $patron->get_routing_lists
Returns the routing lists a patron is subscribed to.
=cut
-sub get_routinglists {
+sub get_routing_lists {
my ($self) = @_;
- my @subscribed_routings = Koha::Subscription::Routinglists->search({ borrowernumber => $self->borrowernumber });
- return @subscribed_routings;
+ return Koha::Subscription::Routinglists->search({ borrowernumber => $self->borrowernumber });
}
=head3 get_age
--- a/Koha/Subscription/Routinglist.pm
+++ a/Koha/Subscription/Routinglist.pm
@@ -45,7 +45,7 @@ Returns the subscription for a routing list.
sub subscription {
my ( $self ) = @_;
- return scalar Koha::Subscriptions->find( $self->subscriptionid );
+ return Koha::Subscription->_new_from_dbic($self->_result->subscriptionid);
}
=head2 Internal methods
--- a/koha-tmpl/opac-tmpl/bootstrap/en/includes/usermenu.inc
+++ a/koha-tmpl/opac-tmpl/bootstrap/en/includes/usermenu.inc
@@ -96,7 +96,7 @@
your lists
[% END %]
- [% IF Koha.Preference( 'RoutingSerials' ) && routing_lists_exist %]
+ [% IF Koha.Preference( 'RoutingSerials' ) && logged_in_user && logged_in_user.get_routing_lists %]
[% IF ( routinglistsview ) %]
[% ELSE %]
--- a/opac/opac-routing-lists.pl
+++ a/opac/opac-routing-lists.pl
@@ -41,11 +41,11 @@ $borrower->{description} = $category->description;
$borrower->{category_type} = $category->category_type;
$template->param( BORROWER_INFO => $borrower );
-my @routinglists = $patron->get_routinglists();
+my @routinglists = $patron->get_routing_lists();
$template->param(
routinglists => \@routinglists,
- routinglistview => 1,
+ routinglistsview => 1,
);
output_html_with_http_headers $query, $cookie, $template->output, undef, { force_no_caching => 1 };
--- a/t/db_dependent/Koha/Patrons.t
+++ a/t/db_dependent/Koha/Patrons.t
@@ -529,7 +529,7 @@ subtest 'checkouts + pending_checkouts + get_overdues + old_checkouts' => sub {
$module->unmock('userenv');
};
-subtest 'get_routinglists' => sub {
+subtest 'get_routing_lists' => sub {
plan tests => 5;
my $biblio = Koha::Biblio->new()->store();
@@ -541,7 +541,7 @@ subtest 'get_routinglists' => sub {
my $patron = $builder->build( { source => 'Borrower' } );
$patron = Koha::Patrons->find( $patron->{borrowernumber} );
- is( $patron->get_routinglists, 0, 'Retrieves correct number of routing lists: 0' );
+ is( $patron->get_routing_lists->count, 0, 'Retrieves correct number of routing lists: 0' );
my $routinglist_count = Koha::Subscription::Routinglists->count;
my $routinglist = Koha::Subscription::Routinglist->new({
@@ -550,11 +550,11 @@ subtest 'get_routinglists' => sub {
subscriptionid => $subscription->subscriptionid
})->store;
- is ($patron->get_routinglists, 1, "Retrieves correct number of routing lists: 1");
+ is ($patron->get_routing_lists->count, 1, "Retrieves correct number of routing lists: 1");
- my @routinglists = $patron->get_routinglists;
+ my @routinglists = $patron->get_routing_lists;
is ($routinglists[0]->ranking, 5, "Retrieves ranking: 5");
- is( ref($routinglists[0]), 'Koha::Subscription::Routinglist', 'get_routinglists returns Koha::Subscription::Routinglist objects' );
+ is( ref($routinglists[0]), 'Koha::Subscription::Routinglist', 'get_routing_lists returns Koha::Subscription::Routinglist objects' );
my $subscription2 = Koha::Subscription->new({
biblionumber => $biblio->biblionumber,
@@ -566,7 +566,7 @@ subtest 'get_routinglists' => sub {
subscriptionid => $subscription2->subscriptionid
})->store;
- is ($patron->get_routinglists, 2, "Retrieves correct number of routing lists: 2");
+ is ($patron->get_routing_lists->count, 2, "Retrieves correct number of routing lists: 2");
$patron->delete; # Clean up for later tests
--