Bug 3150: (follow-up) Make subs to get host/related parts for notices
authorAleisha Amohia <aleishaamohia@hotmail.com>
Mon, 27 Feb 2023 00:26:09 +0000 (00:26 +0000)
committerTomas Cohen Arazi <tomascohen@theke.io>
Mon, 27 Mar 2023 10:49:43 +0000 (12:49 +0200)
Signed-off-by: Katrin Fischer <katrin.fischer@bsz-bw.de>
Signed-off-by: Kyle M Hall <kyle@bywatersolutions.com>
Signed-off-by: Tomas Cohen Arazi <tomascohen@theke.io>
Koha/Biblio.pm
installer/data/mysql/atomicupdate/bug_3150_-_add_LIST_and_CART_notices.pl
installer/data/mysql/en/mandatory/sample_notices.yml
t/db_dependent/Koha/Biblio/host_record.t

index d94bde9..67ec343 100644 (file)
@@ -1322,6 +1322,38 @@ sub get_marc_host {
     }
 }
 
+=head3 get_marc_host_only
+
+    my $host = $biblio->get_marc_host_only;
+
+Return host only
+
+=cut
+
+sub get_marc_host_only {
+    my ($self) = @_;
+
+    my ( $host, $relatedparts ) = $self->get_marc_host;
+
+    return $host;
+}
+
+=head3 get_marc_relatedparts_only
+
+    my $relatedparts = $biblio->get_marc_relatedparts_only;
+
+Return related parts only
+
+=cut
+
+sub get_marc_relatedparts_only {
+    my ($self) = @_;
+
+    my ( $host, $relatedparts ) = $self->get_marc_host;
+
+    return $relatedparts;
+}
+
 =head3 recalls
 
     my $recalls = $biblio->recalls;
index d06071a..c6525f7 100755 (executable)
@@ -28,7 +28,7 @@ Please note that the attached file is a MARC bibliographic records file which ca
 [% IF ( biblio.unititle ) %]Unified title: [% biblio.unititle | html %]<br>[% END %]
 [% IF ( biblio.serial ) %]Serial: [% biblio.serial | html %]<br>[% END %]
 [% IF ( biblioitem.lccn ) %]LCCN: [% biblioitem.lccn | html %]<br>[% END %]
-[% IF ( biblio.get_marc_host ) %]In: [% FOREACH entry IN biblio.get_marc_host %][% entry.title | html %][% IF ( entry.subtitle ) %][% FOREACH subtitle IN entry.subtitle.split(' | ') %][% subtitle | html %][% END %][% END %][% entry.part_number | html %] [% entry.part_name | html %]<br>[% END %][% END %]
+[% IF ( biblio.get_marc_host_only ) %]In: [% FOREACH entry IN biblio.get_marc_host_only %][% entry.title | html %][% IF ( entry.subtitle ) %][% FOREACH subtitle IN entry.subtitle.split(' | ') %][% subtitle | html %][% END %][% END %][% entry.part_number | html %] [% entry.part_name | html %]<br>[% END %] [% biblio.get_marc_relatedparts_only %][% END %]
 [% IF ( biblioitem.url ) %]URL: [% biblioitem.url | html %]<br>[% END %]
 <a href='[% Koha.Preference('OpacBaseUrl') %]/cgi-bin/koha/opac-detail.pl?biblionumber=[% biblio.biblionumber | html %]'>View in online catalog</a>
 [% IF ( biblio.items.count > 0 ) %]<br>Items: <ul>[% FOREACH item IN biblio.items %]<li>[% Branches.GetName( item.holdingbranch ) | html %]
@@ -56,7 +56,7 @@ Please note that the attached file is a MARC bibliographic records file which ca
 [% IF ( biblio.unititle ) %]Unified title: [% biblio.unititle | html %]<br>[% END %]
 [% IF ( biblio.serial ) %]Serial: [% biblio.serial | html %]<br>[% END %]
 [% IF ( biblioitem.lccn ) %]LCCN: [% biblioitem.lccn | html %]<br>[% END %]
-[% IF ( biblio.get_marc_host ) %]In: [% FOREACH entry IN biblio.get_marc_host %][% entry.title | html %][% IF ( entry.subtitle ) %][% FOREACH subtitle IN entry.subtitle.split(' | ') %][% subtitle | html %][% END %][% END %][% entry.part_number | html %] [% entry.part_name | html %]<br>[% END %][% END %]
+[% IF ( biblio.get_marc_host_only ) %]In: [% FOREACH entry IN biblio.get_marc_host_only %][% entry.title | html %][% IF ( entry.subtitle ) %][% FOREACH subtitle IN entry.subtitle.split(' | ') %][% subtitle | html %][% END %][% END %][% entry.part_number | html %] [% entry.part_name | html %]<br>[% END %] [% biblio.get_marc_relatedparts_only %][% END %]
 [% IF ( biblioitem.url ) %]URL: [% biblioitem.url | html %]<br>[% END %]
 <a href='[% Koha.Preference('OpacBaseUrl') %]/cgi-bin/koha/opac-detail.pl?biblionumber=[% biblio.biblionumber | html %]'>View in online catalog</a>
 [% IF ( biblio.items.count > 0 ) %]<br>Items: <ul>[% FOREACH item IN biblio.items %]<li>[% Branches.GetName( item.holdingbranch ) | html %]
index e77f25f..cfe4f8c 100644 (file)
@@ -2318,7 +2318,7 @@ tables:
             - "[% IF ( biblio.unititle ) %]Unified title: [% biblio.unititle | html %]<br>[% END %]"
             - "[% IF ( biblio.serial ) %]Serial: [% biblio.serial | html %]<br>[% END %]"
             - "[% IF ( biblioitem.lccn ) %]LCCN: [% biblioitem.lccn | html %]<br>[% END %]"
-            - "[% IF ( biblio.get_marc_host ) %]In: [% FOREACH entry IN biblio.get_marc_host %][% entry.title | html %][% IF ( entry.subtitle ) %][% FOREACH subtitle IN entry.subtitle.split(' | ') %][% subtitle | html %][% END %][% END %][% entry.part_number | html %] [% entry.part_name | html %]<br>[% END %][% END %]"
+            - "[% IF ( biblio.get_marc_host_only ) %]In: [% FOREACH entry IN biblio.get_marc_host_only %][% entry.title | html %][% IF ( entry.subtitle ) %][% FOREACH subtitle IN entry.subtitle.split(' | ') %][% subtitle | html %][% END %][% END %][% entry.part_number | html %] [% entry.part_name | html %]<br>[% END %] [% biblio.get_marc_relatedparts_only %][% END %]"
             - "[% IF ( biblioitem.url ) %]URL: [% biblioitem.url | html %]<br>[% END %]"
             - "[<a href='[% Koha.Preference('OpacBaseUrl') %]/cgi-bin/koha/opac-detail.pl?biblionumber=[% biblio.biblionumber | html %]'>View in online catalog</a>"
             - "[% IF ( biblio.items.count > 0 ) %]<br>Items: <ul>[% FOREACH item IN biblio.items %]<li>[% Branches.GetName( item.holdingbranch ) | html %]"
@@ -2353,7 +2353,7 @@ tables:
             - "[% IF ( biblio.unititle ) %]Unified title: [% biblio.unititle | html %]<br>[% END %]"
             - "[% IF ( biblio.serial ) %]Serial: [% biblio.serial | html %]<br>[% END %]"
             - "[% IF ( biblioitem.lccn ) %]LCCN: [% biblioitem.lccn | html %]<br>[% END %]"
-            - "[% IF ( biblio.get_marc_host ) %]In: [% FOREACH entry IN biblio.get_marc_host %][% entry.title | html %][% IF ( entry.subtitle ) %][% FOREACH subtitle IN entry.subtitle.split(' | ') %][% subtitle | html %][% END %][% END %][% entry.part_number | html %] [% entry.part_name | html %]<br>[% END %][% END %]"
+            - "[% IF ( biblio.get_marc_host_only ) %]In: [% FOREACH entry IN biblio.get_marc_host_only %][% entry.title | html %][% IF ( entry.subtitle ) %][% FOREACH subtitle IN entry.subtitle.split(' | ') %][% subtitle | html %][% END %][% END %][% entry.part_number | html %] [% entry.part_name | html %]<br>[% END %] [% biblio.get_marc_relatedparts_only %][% END %]"
             - "[% IF ( biblioitem.url ) %]URL: [% biblioitem.url | html %]<br>[% END %]"
             - "<a href='[% Koha.Preference('OpacBaseUrl') %]/cgi-bin/koha/opac-detail.pl?biblionumber=[% biblio.biblionumber | html %]'>View in online catalog</a>"
             - "[% IF ( biblio.items.count > 0 ) %]<br>Items: <ul>[% FOREACH item IN biblio.items %]<li>[% Branches.GetName( item.holdingbranch ) | html %]"
index 4094a10..aab1c36 100755 (executable)
@@ -36,7 +36,7 @@ $schema->storage->txn_begin;
 our $builder = t::lib::TestBuilder->new;
 
 subtest 'get_marc_host' => sub {
-    plan tests => 15;
+    plan tests => 17;
 
     t::lib::Mocks::mock_preference( 'marcflavour', 'MARC21' );
     t::lib::Mocks::mock_preference( 'MARCOrgCode', 'xyz' );
@@ -92,6 +92,12 @@ subtest 'get_marc_host' => sub {
     ( $host, $relatedparts, $info ) = $bib1->get_marc_host;
     is( $host, undef, 'No Koha Biblio object returned with no $w' );
     is( $info, "title, relpart", '773$atg returned when no $w' );
+
+    my $host_only = $bib1->get_marc_host_only;
+    is_deeply( $host_only, $host, "Host only retrieved successfully" );
+    my $relatedparts_only = $bib1->get_marc_relatedparts_only;
+    is_deeply( $relatedparts_only, $relatedparts, "Related parts only retrieved successfully" );
+
     $marc->field('773')->delete_subfield( code => 't' ); # restore
 
     # Add second 773