Bugzilla – Attachment 150538 Details for
Bug 11844
Additional fields for order lines
Home
|
New
|
Browse
|
Search
|
[?]
|
Reports
|
Help
|
New Account
|
Log In
[x]
|
Forgot Password
Login:
[x]
[patch]
Bug 11844: Take into account itemtypes, branches, and cn_source
Bug-11844-Take-into-account-itemtypes-branches-and.patch (text/plain), 9.79 KB, created by
Katrin Fischer
on 2023-05-02 22:03:10 UTC
(
hide
)
Description:
Bug 11844: Take into account itemtypes, branches, and cn_source
Filename:
MIME Type:
Creator:
Katrin Fischer
Created:
2023-05-02 22:03:10 UTC
Size:
9.79 KB
patch
obsolete
>From a910c834bf101d813c4eecb74e02e509a719db5b Mon Sep 17 00:00:00 2001 >From: Julian Maurice <julian.maurice@biblibre.com> >Date: Fri, 20 Jan 2023 17:12:21 +0100 >Subject: [PATCH] Bug 11844: Take into account itemtypes, branches, and > cn_source > >MARC subfields can be linked to "authorised values" that are not real >authorised values: itemtypes, branches, and cn_source. >Those were not taken into account. This patch fixes that > >Test plan: >1. Create additional fields for order lines with a MARC subfield that is > linked to one of those "fake" authorised values list >2. Follow the same steps as in the main test plan > >Signed-off-by: Katrin Fischer <katrin.fischer@bsz-bw.de> >Signed-off-by: Michaela Sieber <michaela.sieber@kit.edu> >Signed-off-by: Martin Renvoize <martin.renvoize@ptfs-europe.com> >--- > Koha/Template/Plugin/ClassSources.pm | 41 +++++++++ > .../en/includes/additional-fields-entry.inc | 39 ++++++-- > .../Koha/Template/Plugin/ClassSources.t | 90 +++++++++++++++++++ > 3 files changed, 165 insertions(+), 5 deletions(-) > create mode 100644 Koha/Template/Plugin/ClassSources.pm > create mode 100755 t/db_dependent/Koha/Template/Plugin/ClassSources.t > >diff --git a/Koha/Template/Plugin/ClassSources.pm b/Koha/Template/Plugin/ClassSources.pm >new file mode 100644 >index 0000000000..7b424f4905 >--- /dev/null >+++ b/Koha/Template/Plugin/ClassSources.pm >@@ -0,0 +1,41 @@ >+package Koha::Template::Plugin::ClassSources; >+ >+# This file is part of Koha. >+# >+# Koha is free software; you can redistribute it and/or modify it >+# under the terms of the GNU General Public License as published by >+# the Free Software Foundation; either version 3 of the License, or >+# (at your option) any later version. >+# >+# Koha is distributed in the hope that it will be useful, but >+# WITHOUT ANY WARRANTY; without even the implied warranty of >+# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the >+# GNU General Public License for more details. >+# >+# You should have received a copy of the GNU General Public License >+# along with Koha; if not, see <http://www.gnu.org/licenses>. >+ >+use Modern::Perl; >+ >+use base qw( Template::Plugin ); >+ >+use C4::Context; >+use Koha::ClassSources; >+ >+sub all { >+ my ($self, $params) = @_; >+ >+ my $selected = $params->{selected}; >+ >+ my $default_source = C4::Context->preference("DefaultClassificationSource"); >+ >+ my @class_sources = grep { >+ $_->used >+ or ( $selected and $_->cn_source eq $selected ) >+ or ( $default_source and $_->cn_source eq $default_source ) >+ } Koha::ClassSources->search->as_list; >+ >+ return @class_sources; >+} >+ >+1; >diff --git a/koha-tmpl/intranet-tmpl/prog/en/includes/additional-fields-entry.inc b/koha-tmpl/intranet-tmpl/prog/en/includes/additional-fields-entry.inc >index 17c7a6f9a2..b16f537090 100644 >--- a/koha-tmpl/intranet-tmpl/prog/en/includes/additional-fields-entry.inc >+++ b/koha-tmpl/intranet-tmpl/prog/en/includes/additional-fields-entry.inc >@@ -1,4 +1,7 @@ > [% USE AuthorisedValues %] >+[% USE Branches %] >+[% USE ClassSources %] >+[% USE ItemTypes %] > [% IF wrap_fieldset != 0 %] > <fieldset class="rows"> > <legend>Additional fields</legend> >@@ -15,11 +18,37 @@ > <select name="additional_field_[% field.id | html %]" id="additional_field_[% field.id | html %]"> > [% END %] > <option value=""></option> >- [% FOREACH av IN AuthorisedValues.GetAuthValueDropbox( authorised_value_category ) %] >- [% IF av.authorised_value == values.${field.id} %] >- <option value="[% av.authorised_value | html %]" selected="selected">[% av.lib | html %]</option> >- [% ELSE %] >- <option value="[% av.authorised_value | html %]">[% av.lib | html %]</option> >+ [% IF authorised_value_category == 'branches' %] >+ [% FOREACH branch IN Branches.all() %] >+ [% IF branch.branchcode == values.${field.id} %] >+ <option value="[% branch.branchcode | html %]" selected="selected">[% branch.branchname | html %]</option> >+ [% ELSE %] >+ <option value="[% branch.branchcode | html %]">[% branch.branchname | html %]</option> >+ [% END %] >+ [% END %] >+ [% ELSIF authorised_value_category == 'cn_source' %] >+ [% FOREACH class_source IN ClassSources.all({ selected => values.${field.id} }) %] >+ [% IF class_source.cn_source == values.${field.id} %] >+ <option value="[% class_source.cn_source | html %]" selected="selected">[% class_source.description | html %]</option> >+ [% ELSE %] >+ <option value="[% class_source.cn_source | html %]">[% class_source.description | html %]</option> >+ [% END %] >+ [% END %] >+ [% ELSIF authorised_value_category == 'itemtypes' %] >+ [% FOREACH itemtype IN ItemTypes.Get() %] >+ [% IF itemtype.itemtype == values.${field.id} %] >+ <option value="[% itemtype.itemtype | html %]" selected="selected">[% itemtype.description | html %]</option> >+ [% ELSE %] >+ <option value="[% itemtype.itemtype | html %]">[% itemtype.description | html %]</option> >+ [% END %] >+ [% END %] >+ [% ELSE %] >+ [% FOREACH av IN AuthorisedValues.GetAuthValueDropbox( authorised_value_category ) %] >+ [% IF av.authorised_value == values.${field.id} %] >+ <option value="[% av.authorised_value | html %]" selected="selected">[% av.lib | html %]</option> >+ [% ELSE %] >+ <option value="[% av.authorised_value | html %]">[% av.lib | html %]</option> >+ [% END %] > [% END %] > [% END %] > </select> <span>(Authorised values for [% authorised_value_category | html %])</span> >diff --git a/t/db_dependent/Koha/Template/Plugin/ClassSources.t b/t/db_dependent/Koha/Template/Plugin/ClassSources.t >new file mode 100755 >index 0000000000..d897838b7d >--- /dev/null >+++ b/t/db_dependent/Koha/Template/Plugin/ClassSources.t >@@ -0,0 +1,90 @@ >+#!/usr/bin/perl >+ >+# This file is part of Koha. >+# >+# Koha is free software; you can redistribute it and/or modify it under the >+# terms of the GNU General Public License as published by the Free Software >+# Foundation; either version 3 of the License, or (at your option) any later >+# version. >+# >+# Koha is distributed in the hope that it will be useful, but WITHOUT ANY >+# WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR >+# A PARTICULAR PURPOSE. See the GNU General Public License for more details. >+# >+# You should have received a copy of the GNU General Public License along >+# with Koha; if not, see <http://www.gnu.org/licenses>. >+ >+use Modern::Perl; >+ >+use Test::More tests => 2; >+ >+use t::lib::Mocks; >+ >+BEGIN { >+ use_ok('Koha::Template::Plugin::ClassSources'); >+} >+ >+my $schema = Koha::Database->schema; >+ >+subtest 'all' => sub { >+ plan tests => 4; >+ >+ $schema->storage->txn_begin; >+ $schema->resultset('ClassSource')->delete(); >+ $schema->resultset('ClassSource')->create({ >+ cn_source => 'anscr', >+ description => 'ANSCR (Sound Recordings)', >+ used => 0, >+ class_sort_rule => 'generic', >+ class_split_rule => 'generic', >+ }); >+ $schema->resultset('ClassSource')->create({ >+ cn_source => 'ddc', >+ description => 'Dewey Decimal Classification', >+ used => 1, >+ class_sort_rule => 'dewey', >+ class_split_rule => 'dewey', >+ }); >+ $schema->resultset('ClassSource')->create({ >+ cn_source => 'z', >+ description => 'Other/Generic Classification Scheme', >+ used => 0, >+ class_sort_rule => 'generic', >+ class_split_rule => 'generic', >+ }); >+ >+ t::lib::Mocks::mock_preference('DefaultClassificationSource', ''); >+ >+ my $plugin = Koha::Template::Plugin::ClassSources->new(); >+ subtest 'when given no parameters' => sub { >+ plan tests => 2; >+ my @class_sources = $plugin->all(); >+ >+ is(scalar @class_sources, 1, 'it returns only "used" class sources'); >+ is($class_sources[0]->used, 1, 'it returns only "used" class sources'); >+ }; >+ >+ subtest 'when given parameter "selected"' => sub { >+ plan tests => 1; >+ my @class_sources = $plugin->all({ selected => 'anscr' }); >+ >+ ok(scalar @class_sources == 2, 'it returns "used" class sources and the selected one'); >+ }; >+ >+ subtest 'when DefaultClassificationSource is set to a not used class source' => sub { >+ plan tests => 1; >+ t::lib::Mocks::mock_preference('DefaultClassificationSource', 'anscr'); >+ my @class_sources = $plugin->all(); >+ >+ ok(scalar @class_sources == 2, 'it returns "used" class sources and the default one'); >+ }; >+ >+ subtest 'when DefaultClassificationSource is set and "selected" parameter is given' => sub { >+ plan tests => 1; >+ t::lib::Mocks::mock_preference('DefaultClassificationSource', 'anscr'); >+ my @class_sources = $plugin->all({ selected => 'z' }); >+ ok(scalar @class_sources == 3, 'it returns "used" class sources, the default one and the selected one'); >+ }; >+ >+ $schema->storage->txn_rollback; >+}; >-- >2.30.2
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 11844
:
25632
|
25638
|
41859
|
41860
|
45674
|
45675
|
45676
|
45758
|
45915
|
45916
|
45917
|
53614
|
53615
|
53616
|
53618
|
53619
|
55529
|
75332
|
75362
|
141116
|
145517
|
145535
|
145536
|
145540
|
146497
|
146500
|
146501
|
146502
|
146503
|
146504
|
146505
|
146506
|
148889
|
148895
|
148897
|
149081
|
149082
|
149083
|
149084
|
149085
|
149086
|
149087
|
149088
|
149089
|
149090
|
149091
|
149682
|
149683
|
149684
|
149685
|
149686
|
149687
|
149688
|
149689
|
149690
|
149691
|
149692
|
150537
|
150538
|
150539
|
150540
|
150541
|
150542
|
150543
|
150544
|
150545
|
150546
|
150547
|
150548
|
151220
|
151221
|
151222
|
151223
|
151224
|
151225
|
151226
|
151227
|
151228
|
151229
|
151230
|
151366