Bugzilla – Attachment 118804 Details for
Bug 21260
Improve the Availability line of OPAC XSLT search results
Home
|
New
|
Browse
|
Search
|
[?]
|
Reports
|
Help
|
New Account
|
Log In
[x]
|
Forgot Password
Login:
[x]
[patch]
Bug 21260: Introduce local pref to affect status grouping
Bug-21260-Introduce-local-pref-to-affect-status-gr.patch (text/plain), 4.38 KB, created by
Martin Renvoize (ashimema)
on 2021-03-25 13:51:29 UTC
(
hide
)
Description:
Bug 21260: Introduce local pref to affect status grouping
Filename:
MIME Type:
Creator:
Martin Renvoize (ashimema)
Created:
2021-03-25 13:51:29 UTC
Size:
4.38 KB
patch
obsolete
>From 45c03fd4ff918d14bf188a5e2f07a567928a1be3 Mon Sep 17 00:00:00 2001 >From: Marcel de Rooy <m.de.rooy@rijksmuseum.nl> >Date: Wed, 19 Aug 2020 16:52:13 +0200 >Subject: [PATCH] Bug 21260: Introduce local pref to affect status grouping > >Introducing a local preference Available_NFL to control which not for >loan statuses are considered to be 'available for reference'. >Standard value is '1|2' which comes down to the former >0 when using >the initial Koha defaults. > >Test plan: >[1] Pick a biblio with an available item A, an item B with notforloan 1, > an item C with notforloan 2 and two damaged items. (Former patch.) > Include it in a OPAC search. You should see: > Available: A. Reference: B, C. Not-available: Damaged(2). >[2] Add local pref Available_NFL with value '1'. Repeat the search. > You should see now: > Available: A. Reference: B. Not-available: S.C.(1), Damaged(2). > [where S.C. stands for Staff Collection] >[3] Run test t/db_dependent/XSLT.t > >Signed-off-by: Marcel de Rooy <m.de.rooy@rijksmuseum.nl> >Signed-off-by: ava li <rubyli208@gmail.com> >Signed-off-by: Martin Renvoize <martin.renvoize@ptfs-europe.com> >--- > C4/XSLT.pm | 11 ++++++++--- > t/db_dependent/XSLT.t | 12 ++++++++++-- > 2 files changed, 18 insertions(+), 5 deletions(-) > >diff --git a/C4/XSLT.pm b/C4/XSLT.pm >index 0484c2b733..cd183fbe51 100644 >--- a/C4/XSLT.pm >+++ b/C4/XSLT.pm >@@ -316,6 +316,7 @@ sub buildKohaItemsNamespace { > my $itemtypes = { map { $_->{itemtype} => $_ } @{ Koha::ItemTypes->search->unblessed } }; > my $xml = ''; > my %descs = map { $_->{authorised_value} => $_ } Koha::AuthorisedValues->get_descriptions_by_koha_field( { kohafield => 'items.notforloan' } ); >+ my $ref_status = C4::Context->preference('Available_NFL') || '1|2'; > > for my $item (@items) { > my $status; >@@ -343,13 +344,17 @@ sub buildKohaItemsNamespace { > $status = "Checked out"; > } > elsif ( $item->notforloan ) { >- $status = $item->notforloan < 0 ? "reallynotforloan" : "reference"; >- $substatus = exists $descs{$item->notforloan} ? $descs{$item->notforloan}->{opac_description} : "Not for loan_".$item->notforloan; >+ $status = $item->notforloan =~ /^($ref_status)$/ >+ ? "reference" >+ : "reallynotforloan"; >+ $substatus = exists $descs{$item->notforloan} ? $descs{$item->notforloan}->{opac_description} : "Not for loan"; > } > elsif ( exists $itemtypes->{ $item->effective_itemtype } > && $itemtypes->{ $item->effective_itemtype }->{notforloan} == 1 ) > { >- $status = "reference"; >+ $status = "1" =~ /^($ref_status)$/ >+ ? "reference" >+ : "reallynotforloan"; > $substatus = "Not for loan"; > } > else { >diff --git a/t/db_dependent/XSLT.t b/t/db_dependent/XSLT.t >index befce88e5c..16487db5ec 100755 >--- a/t/db_dependent/XSLT.t >+++ b/t/db_dependent/XSLT.t >@@ -34,7 +34,10 @@ my $builder = t::lib::TestBuilder->new; > $schema->storage->txn_begin; > > subtest 'buildKohaItemsNamespace status tests' => sub { >- plan tests => 13; >+ plan tests => 14; >+ >+ t::lib::Mocks::mock_preference('Available_NFL', '1|2'); >+ > my $itype = $builder->build_object({ class => 'Koha::ItemTypes' }); > my $itemtype = $builder->build_object({ class => 'Koha::ItemTypes' }); > my $item = $builder->build_sample_item({ itype => $itype->itemtype }); >@@ -45,7 +48,6 @@ subtest 'buildKohaItemsNamespace status tests' => sub { > > # notforloan > { >- > t::lib::Mocks::mock_preference('item-level_itypes', 0); > $item->notforloan(0)->store; > Koha::ItemTypes->find($item->itype)->notforloan(0)->store; >@@ -69,6 +71,12 @@ subtest 'buildKohaItemsNamespace status tests' => sub { > $item->notforloan(1)->store; > $xml = C4::XSLT::buildKohaItemsNamespace( $item->biblionumber,[]); > like($xml,qr{<status>reference</status>},"reference if positive notforloan value"); >+ >+ # But now make status notforloan==1 count under Not available >+ t::lib::Mocks::mock_preference('Available_NFL', '2'); >+ $xml = C4::XSLT::buildKohaItemsNamespace( $item->biblionumber,[]); >+ like($xml,qr{<status>reallynotforloan</status>},"reallynotforloan when we change Avaiable_NFL"); >+ t::lib::Mocks::mock_preference('Available_NFL', '1|2'); > } > > $item->onloan('2001-01-01')->store; >-- >2.20.1
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 21260
:
105375
|
105376
|
109107
|
109108
|
109109
|
109110
|
109111
|
109112
|
109182
|
115265
|
115266
|
115267
|
115268
|
115269
|
115270
|
115271
|
118800
|
118801
|
118802
|
118803
| 118804 |
118805
|
118806
|
119569