Bug 29844: Simplify Koha::Clubs->get_enrollable

This patch removes the wantarray use in Koha::Clubs->get_enrollable and
adjusts the callers.

Also, reference to some unused params in Koha::Patron clubs-related
methods are removed as well.

Signed-off-by: Tomas Cohen Arazi <tomascohen@theke.io>
Signed-off-by: Martin Renvoize <martin.renvoize@ptfs-europe.com>
Signed-off-by: Fridolin Somers <fridolin.somers@biblibre.com>
This commit is contained in:
Tomas Cohen Arazi 2022-02-03 10:54:25 -03:00 committed by Fridolin Somers
parent 0bec03e861
commit db0ebb3ab5
5 changed files with 9 additions and 21 deletions

View File

@ -70,19 +70,7 @@ sub get_enrollable {
]
];
my $rs = $self->_resultset()->search( $params, { prefetch => 'club_template' } );
if (wantarray) {
my $class = ref($self) ? ref($self) : $self;
return $class->_wrap( $rs->all() );
}
else {
my $class = ref($self) ? ref($self) : $self;
return $class->_new_from_dbic($rs);
}
return $self->search( $params, { prefetch => 'club_template' } );
}
=head3 filter_out_empty

View File

@ -1355,7 +1355,7 @@ sub first_valid_email_address {
=cut
sub get_club_enrollments {
my ( $self, $return_scalar ) = @_;
my ( $self ) = @_;
return Koha::Club::Enrollments->search( { borrowernumber => $self->borrowernumber(), date_canceled => undef } );
}
@ -1365,7 +1365,7 @@ sub get_club_enrollments {
=cut
sub get_enrollable_clubs {
my ( $self, $is_enrollable_from_opac, $return_scalar ) = @_;
my ( $self, $is_enrollable_from_opac ) = @_;
my $params;
$params->{is_enrollable_from_opac} = $is_enrollable_from_opac

View File

@ -805,8 +805,8 @@
<li><a id="debarments-tab-link" href="#reldebarments">[% debarments.count | html %] Restrictions</a></li>
[% SET enrollments = patron.get_club_enrollments(1) %]
[% SET enrollable = patron.get_enrollable_clubs(0,1) %]
[% SET enrollments = patron.get_club_enrollments %]
[% SET enrollable = patron.get_enrollable_clubs(0) %] <!-- 0 => not OPAC -->
[% IF CAN_user_clubs && ( enrollable.count || enrollments.count ) %]
<li>
<a id="clubs-tab-link" href="#clubs-tab">

View File

@ -732,8 +732,8 @@
<li>
<a id="debarments-tab-link" href="#reldebarments">[% debarments.size | html %] Restrictions</a>
</li>
[% SET enrollments = patron.get_club_enrollments(1) %]
[% SET enrollable = patron.get_enrollable_clubs(0,1) %]
[% SET enrollments = patron.get_club_enrollments %]
[% SET enrollable = patron.get_enrollable_clubs(0) %] <!-- 0 => not OPAC -->
[% IF CAN_user_clubs && ( enrollable.count || enrollments.count ) %]
<li>
<a id="clubs-tab-link" href="#clubs-tab">

View File

@ -10,8 +10,8 @@
[% SET OpacNav = AdditionalContents.get( location => "OpacNav", lang => lang, library => logged_in_user.branchcode, blocktitle => 0 ) %]
[% SET OpacNavBottom = AdditionalContents.get( location => "OpacNavBottom", lang => lang, library => logged_in_user.branchcode, blocktitle => 0 ) %]
[% SET borrower_club_enrollments = logged_in_user.get_club_enrollments(1) %]
[% SET borrower_enrollable_clubs = logged_in_user.get_enrollable_clubs(1,1) %]
[% SET borrower_club_enrollments = logged_in_user.get_club_enrollments %]
[% SET borrower_enrollable_clubs = logged_in_user.get_enrollable_clubs(1) %] <!-- 1 => OPAC -->
[% INCLUDE 'doc-head-open.inc' %]
<title>Your library home &rsaquo; [% IF ( LibraryNameTitle ) %][% LibraryNameTitle | html %][% ELSE %]Koha online[% END %] catalog</title>