Bugzilla – Attachment 78368 Details for
Bug 17530
Don't show 'article request' link when no article requests are permitted
Home
|
New
|
Browse
|
Search
|
[?]
|
Reports
|
Help
|
New Account
|
Log In
[x]
|
Forgot Password
Login:
[x]
[patch]
Bug 17530: (QA follow-up) Add pref ArticleRequestsLinkControl
Bug-17530-QA-follow-up-Add-pref-ArticleRequestsLin.patch (text/plain), 7.77 KB, created by
Marcel de Rooy
on 2018-09-03 11:16:11 UTC
(
hide
)
Description:
Bug 17530: (QA follow-up) Add pref ArticleRequestsLinkControl
Filename:
MIME Type:
Creator:
Marcel de Rooy
Created:
2018-09-03 11:16:11 UTC
Size:
7.77 KB
patch
obsolete
>From 16eac8bb0a9ad2dfb03d2fc1584e7b01185f02e7 Mon Sep 17 00:00:00 2001 >From: Marcel de Rooy <m.de.rooy@rijksmuseum.nl> >Date: Mon, 3 Sep 2018 11:49:08 +0200 >Subject: [PATCH] Bug 17530: (QA follow-up) Add pref ArticleRequestsLinkControl >Content-Type: text/plain; charset=utf-8 > >As requested by RM on Bugzilla comment53. > >This pref allows you to always display the link on search results. >Which is the previous behavior ;) It will raise false positives, whereas >the algorithm may result in false positives or negatives (depending on >default item type and circulation rules). > >When upgrading the pref is set to always (current behavior), new installs >get the new calc value using the algorithm in may_article_request. > >Test plan: >Run t/db_dependent/Koha/IssuingRules/guess_article_requestable_itemtypes.t >Run t/db_dependent/ArticleRequests.t > >Signed-off-by: Marcel de Rooy <m.de.rooy@rijksmuseum.nl> >--- > Koha/IssuingRules.pm | 3 +++ > installer/data/mysql/atomicupdate/bug_17530.perl | 8 ++++++++ > installer/data/mysql/sysprefs.sql | 1 + > .../prog/en/modules/admin/preferences/circulation.pref | 6 ++++++ > t/db_dependent/ArticleRequests.t | 5 ++++- > .../Koha/IssuingRules/guess_article_requestable_itemtypes.t | 8 +++++++- > 6 files changed, 29 insertions(+), 2 deletions(-) > create mode 100644 installer/data/mysql/atomicupdate/bug_17530.perl > >diff --git a/Koha/IssuingRules.pm b/Koha/IssuingRules.pm >index 37cc45c..9ec3ee5 100644 >--- a/Koha/IssuingRules.pm >+++ b/Koha/IssuingRules.pm >@@ -150,6 +150,8 @@ sub article_requestable_rules { > 'article requested'. Constructed by an intelligent guess in the > issuing rules (see article_requestable_rules). > >+ Note: pref ArticleRequestsLinkControl overrides the algorithm. >+ > Optional parameters: categorycode. > > Note: the routine is used in opac-search to obtain a reasonable >@@ -164,6 +166,7 @@ sub guess_article_requestable_itemtypes { > my ( $class, $params ) = @_; > my $category = $params->{categorycode}; > return {} if !C4::Context->preference('ArticleRequests'); >+ return { '*' => 1 } if C4::Context->preference('ArticleRequestsLinkControl') eq 'always'; > > my $cache = Koha::Caches->get_instance; > my $last_article_requestable_guesses = $cache->get_from_cache(GUESSED_ITEMTYPES_KEY); >diff --git a/installer/data/mysql/atomicupdate/bug_17530.perl b/installer/data/mysql/atomicupdate/bug_17530.perl >new file mode 100644 >index 0000000..9e2156f >--- /dev/null >+++ b/installer/data/mysql/atomicupdate/bug_17530.perl >@@ -0,0 +1,8 @@ >+$DBversion = 'XXX'; # will be replaced by the RM >+if( CheckVersion( $DBversion ) ) { >+ $dbh->do(q| >+INSERT IGNORE INTO systempreferences (variable, value, options, explanation, type) VALUES ('ArticleRequestsLinkControl', 'always', 'always\|calc', 'Control display of article request link on search results', 'Choice') >+ |); >+ SetVersion( $DBversion ); >+ print "Upgrade to $DBversion done (Bug 17530 - Add pref ArticleRequestsLinkControl)\n"; >+} >diff --git a/installer/data/mysql/sysprefs.sql b/installer/data/mysql/sysprefs.sql >index dab6b6b..c919a8c 100644 >--- a/installer/data/mysql/sysprefs.sql >+++ b/installer/data/mysql/sysprefs.sql >@@ -47,6 +47,7 @@ INSERT INTO systempreferences ( `variable`, `value`, `options`, `explanation`, ` > ('AnonSuggestions','0',NULL,'Set to enable Anonymous suggestions to AnonymousPatron borrowernumber','YesNo'), > ('AnonymousPatron','0',NULL,'Set the identifier (borrowernumber) of the anonymous patron. Used for Suggestion and reading history privacy',''), > ('ArticleRequests', '0', NULL, 'Enables the article request feature', 'YesNo'), >+('ArticleRequestsLinkControl', 'calc', 'always|calc', 'Control display of article request link on search results', 'Choice'), > ('ArticleRequestsMandatoryFields', '', NULL, 'Comma delimited list of required fields for bibs where article requests rule = ''yes''', 'multiple'), > ('ArticleRequestsMandatoryFieldsItemsOnly', '', NULL, 'Comma delimited list of required fields for bibs where article requests rule = ''item_only''', 'multiple'), > ('ArticleRequestsMandatoryFieldsRecordOnly', '', NULL, 'Comma delimited list of required fields for bibs where article requests rule = ''bib_only''', 'multiple'), >diff --git a/koha-tmpl/intranet-tmpl/prog/en/modules/admin/preferences/circulation.pref b/koha-tmpl/intranet-tmpl/prog/en/modules/admin/preferences/circulation.pref >index a7a1df1..c7193df 100644 >--- a/koha-tmpl/intranet-tmpl/prog/en/modules/admin/preferences/circulation.pref >+++ b/koha-tmpl/intranet-tmpl/prog/en/modules/admin/preferences/circulation.pref >@@ -944,6 +944,12 @@ Circulation: > no: "Don't enable" > - patrons to place article requests. > - >+ - pref: ArticleRequestsLinkControl >+ choices: >+ always: Always show >+ calc: Use algorithm to show or hide >+ - article request link on search results. >+ - > - For records that are record level or item level requestable, make the following fields mandatory > - pref: ArticleRequestsMandatoryFields > multiple: >diff --git a/t/db_dependent/ArticleRequests.t b/t/db_dependent/ArticleRequests.t >index 65b3288..884c2e2 100755 >--- a/t/db_dependent/ArticleRequests.t >+++ b/t/db_dependent/ArticleRequests.t >@@ -221,10 +221,11 @@ subtest 'search_limited' => sub { > }; > > subtest 'may_article_request' => sub { >- plan tests => 3; >+ plan tests => 4; > > # mocking > t::lib::Mocks::mock_preference('ArticleRequests', 1); >+ t::lib::Mocks::mock_preference('ArticleRequestsLinkControl', 'calc'); > $cache->set_in_cache( Koha::IssuingRules::GUESSED_ITEMTYPES_KEY, { > '*' => { 'CR' => 1 }, > 'S' => { '*' => 1 }, >@@ -235,6 +236,8 @@ subtest 'may_article_request' => sub { > is( $itemtype->may_article_request, 1, 'SER/* should be true' ); > is( $itemtype->may_article_request({ categorycode => 'S' }), 1, 'SER/S should be true' ); > is( $itemtype->may_article_request({ categorycode => 'PT' }), '', 'SER/PT should be false' ); >+ t::lib::Mocks::mock_preference('ArticleRequestsLinkControl', 'always'); >+ is( $itemtype->may_article_request({ categorycode => 'PT' }), '1', 'Result should be true when LinkControl is set to always' ); > > # Cleanup > $cache->clear_from_cache( Koha::IssuingRules::GUESSED_ITEMTYPES_KEY ); >diff --git a/t/db_dependent/Koha/IssuingRules/guess_article_requestable_itemtypes.t b/t/db_dependent/Koha/IssuingRules/guess_article_requestable_itemtypes.t >index 5552918..ae716db 100644 >--- a/t/db_dependent/Koha/IssuingRules/guess_article_requestable_itemtypes.t >+++ b/t/db_dependent/Koha/IssuingRules/guess_article_requestable_itemtypes.t >@@ -15,9 +15,10 @@ our $builder = t::lib::TestBuilder->new; > our $cache = Koha::Caches->get_instance; > > subtest 'guess_article_requestable_itemtypes' => sub { >- plan tests => 12; >+ plan tests => 13; > > t::lib::Mocks::mock_preference('ArticleRequests', 1); >+ t::lib::Mocks::mock_preference('ArticleRequestsLinkControl', 'calc'); > $cache->clear_from_cache( Koha::IssuingRules::GUESSED_ITEMTYPES_KEY ); > Koha::IssuingRules->delete; > my $itype1 = $builder->build_object({ class => 'Koha::ItemTypes' }); >@@ -64,6 +65,11 @@ subtest 'guess_article_requestable_itemtypes' => sub { > is( $res->{$itype1->itemtype}, 1, 'Item type 1 seems permitted' ); > is( $res->{$itype2->itemtype}, undef, 'Item type 2 seems not permitted' ); > >+ # Finally test the overriding pref >+ t::lib::Mocks::mock_preference('ArticleRequestsLinkControl', 'always'); >+ $res = Koha::IssuingRules->guess_article_requestable_itemtypes({}); >+ is( $res->{'*'}, 1, 'Override algorithm with pref setting' ); >+ > $cache->clear_from_cache( Koha::IssuingRules::GUESSED_ITEMTYPES_KEY ); > }; > >-- >2.1.4
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 17530
:
72857
|
72858
|
72859
|
72860
|
72909
|
72910
|
72911
|
72912
|
72913
|
72914
|
72915
|
72930
|
72931
|
75697
|
75751
|
76617
|
76618
|
76619
|
76620
|
76621
|
76622
|
77258
|
77259
|
77260
|
77261
|
77262
|
77263
|
78030
|
78031
|
78032
|
78033
|
78034
|
78035
|
78362
|
78363
|
78364
|
78365
|
78366
|
78367
| 78368 |
78499