Bugzilla – Attachment 45750 Details for
Bug 14828
Move the item types related code to Koha::ItemTypes
Home
|
New
|
Browse
|
Search
|
[?]
|
Reports
|
Help
|
New Account
|
Log In
[x]
|
Forgot Password
Login:
[x]
[patch]
Bug 14828: Use Koha::ItemType[s] everywhere C4::ItemType was used
Bug-14828-Use-KohaItemTypes-everywhere-C4ItemType-.patch (text/plain), 10.76 KB, created by
Jonathan Druart
on 2015-12-17 10:09:07 UTC
(
hide
)
Description:
Bug 14828: Use Koha::ItemType[s] everywhere C4::ItemType was used
Filename:
MIME Type:
Creator:
Jonathan Druart
Created:
2015-12-17 10:09:07 UTC
Size:
10.76 KB
patch
obsolete
>From b1f514ba0bd6c0f5c0903050eacc432b40f688bf Mon Sep 17 00:00:00 2001 >From: Jonathan Druart <jonathan.druart@bugs.koha-community.org> >Date: Tue, 15 Sep 2015 17:03:04 +0100 >Subject: [PATCH] Bug 14828: Use Koha::ItemType[s] everywhere C4::ItemType was > used > >This patch mainly replaces C4::ItemType->all with >Koha::ItemTypes->search. > >Test plan: >At the places where the C4::ItemType module was used, confirm there is >no regression: >- acqui/neworderempty.pl >- catalogue/itemsearch.pl >- admin/item_circulation_alerts.pl >and the 2 cataloguing plugins: >- marc21_linking_section.pl >- unimarc_field_4XX.pl > >QA step: >prove t/db_dependent/HoldsQueue.t should return green >Note that the tests were buggy. >--- > C4/ItemCirculationAlertPreference.pm | 5 +++-- > acqui/neworderempty.pl | 3 ++- > admin/item_circulation_alerts.pl | 18 +++--------------- > catalogue/itemsearch.pl | 12 +++++++----- > cataloguing/value_builder/marc21_linking_section.pl | 5 +++-- > cataloguing/value_builder/unimarc_field_4XX.pl | 5 +++-- > circ/returns.pl | 10 +++++----- > .../prog/en/modules/admin/item_circulation_alerts.tt | 4 ++-- > t/db_dependent/HoldsQueue.t | 16 +++++++++------- > 9 files changed, 37 insertions(+), 41 deletions(-) > >diff --git a/C4/ItemCirculationAlertPreference.pm b/C4/ItemCirculationAlertPreference.pm >index 90b4cfd..4f04a25 100644 >--- a/C4/ItemCirculationAlertPreference.pm >+++ b/C4/ItemCirculationAlertPreference.pm >@@ -21,9 +21,10 @@ use strict; > use warnings; > use C4::Context; > use C4::Category; >-use C4::ItemType; > use Carp qw(carp croak); > >+use Koha::ItemTypes; >+ > our $AUTOLOAD; > > # helper function for validating \%opts >@@ -331,7 +332,7 @@ sub grid { > my @branch_prefs = $class->find($where); > my @default_prefs = $class->find({ branchcode => '*', notification => $where->{notification} }); > my @cc = C4::Category->all; >- my @it = C4::ItemType->all; >+ my @it = Koha::ItemTypes->search; > my $notification = $where->{notification}; > my %disabled = map { > my $key = $_->categorycode . "-" . $_->item_type . "-" . $notification; >diff --git a/acqui/neworderempty.pl b/acqui/neworderempty.pl >index 4a37815..efd6648 100755 >--- a/acqui/neworderempty.pl >+++ b/acqui/neworderempty.pl >@@ -89,6 +89,7 @@ use C4::Search qw/FindDuplicate/; > use C4::ImportBatch qw/GetImportRecordMarc SetImportRecordStatus/; > > use Koha::Acquisition::Bookseller; >+use Koha::ItemTypes; > > our $input = new CGI; > my $booksellerid = $input->param('booksellerid'); # FIXME: else ERROR! >@@ -303,7 +304,7 @@ if (C4::Context->preference('AcqCreateItem') eq 'ordering' && !$ordernumber) { > } > # Get the item types list, but only if item_level_itype is YES. Otherwise, it will be in the item, no need to display it in the biblio > my @itemtypes; >-@itemtypes = C4::ItemType->all unless C4::Context->preference('item-level_itypes'); >+@itemtypes = Koha::ItemTypes->search unless C4::Context->preference('item-level_itypes'); > > if ( defined $subscriptionid ) { > my $lastOrderReceived = GetLastOrderReceivedFromSubscriptionid $subscriptionid; >diff --git a/admin/item_circulation_alerts.pl b/admin/item_circulation_alerts.pl >index 684a12d..ca253aa 100755 >--- a/admin/item_circulation_alerts.pl >+++ b/admin/item_circulation_alerts.pl >@@ -28,24 +28,14 @@ use C4::Auth; > use C4::Context; > use C4::Branch; > use C4::Category; >-use C4::ItemType; > use C4::ItemCirculationAlertPreference; > use C4::Output; > >+use Koha::ItemTypes; >+ > # shortcut for long package name > our $preferences = 'C4::ItemCirculationAlertPreference'; > >-# prepend "br_" to column name and replace spaces with "<br/>" >-sub br { >- my ($data, @keys) = @_; >- for (@keys) { >- my $br = $data->{$_}; >- $br =~ s{\s+}{<br/>}g; >- $data->{'br_'.$_} = $br; >- } >- $data; >-} >- > # display item circulation alerts > sub show { > my ($input) = @_; >@@ -78,9 +68,7 @@ sub show { > my @categories = ( > C4::Category->all > ); >- my @item_types = map { br($_, 'description') } ( >- C4::ItemType->all >- ); >+ my @item_types = Koha::ItemTypes->search; > my $grid_checkout = $preferences->grid({ branchcode => $branch, notification => 'CHECKOUT' }); > my $grid_checkin = $preferences->grid({ branchcode => $branch, notification => 'CHECKIN' }); > >diff --git a/catalogue/itemsearch.pl b/catalogue/itemsearch.pl >index c1253d7..dfe1bc5 100755 >--- a/catalogue/itemsearch.pl >+++ b/catalogue/itemsearch.pl >@@ -27,9 +27,9 @@ use C4::Items; > use C4::Biblio; > use C4::Branch; > use C4::Koha; >-use C4::ItemType; > > use Koha::Item::Search::Field qw(GetItemSearchFields); >+use Koha::ItemTypes; > > my $cgi = new CGI; > my %params = $cgi->Vars; >@@ -255,10 +255,12 @@ if ($format eq 'html') { > label => $location->{lib} // $location->{authorised_value}, > }; > } >- my @itemtypes = C4::ItemType->all(); >- foreach my $itemtype (@itemtypes) { >- $itemtype->{value} = $itemtype->{itemtype}; >- $itemtype->{label} = $itemtype->{translated_description}; >+ my @itemtypes; >+ foreach my $itemtype ( Koha::ItemTypes->search ) { >+ push @itemtypes, { >+ value => $itemtype->itemtype, >+ label => $itemtype->translated_description, >+ }; > } > my $ccode_avcode = GetAuthValCode('items.ccode') || 'CCODE'; > my $ccodes = GetAuthorisedValues($ccode_avcode); >diff --git a/cataloguing/value_builder/marc21_linking_section.pl b/cataloguing/value_builder/marc21_linking_section.pl >index 13f3a64..70d581b 100755 >--- a/cataloguing/value_builder/marc21_linking_section.pl >+++ b/cataloguing/value_builder/marc21_linking_section.pl >@@ -32,7 +32,8 @@ use C4::Biblio; > use C4::Koha; > use MARC::Record; > use C4::Branch; >-use C4::ItemType; >+ >+use Koha::ItemTypes; > > my $builder = sub { > my ( $params ) = @_; >@@ -304,7 +305,7 @@ my $launcher = sub { > } > ); > >- my @itemtypes = C4::ItemType->all; >+ my @itemtypes = Koha::ItemTypes->search; > > $template->param( > itypeloop => \@itemtypes, >diff --git a/cataloguing/value_builder/unimarc_field_4XX.pl b/cataloguing/value_builder/unimarc_field_4XX.pl >index a378618..9b342db 100755 >--- a/cataloguing/value_builder/unimarc_field_4XX.pl >+++ b/cataloguing/value_builder/unimarc_field_4XX.pl >@@ -32,7 +32,8 @@ use C4::Biblio; > use C4::Koha; > use MARC::Record; > use C4::Branch; # GetBranches >-use C4::ItemType; >+ >+use Koha::ItemTypes; > > sub plugin_javascript { > my ( $dbh, $record, $tagslib, $field_number, $tabloop ) = @_; >@@ -508,7 +509,7 @@ sub plugin { > } > ); > >- my @itemtypes = C4::ItemType->all; >+ my @itemtypes = Koha::ItemTypes->search; > > $template->param( #classlist => $classlist, > itypeloop => \@itemtypes, >diff --git a/circ/returns.pl b/circ/returns.pl >index 893accd..2192891 100755 >--- a/circ/returns.pl >+++ b/circ/returns.pl >@@ -265,16 +265,16 @@ if ($barcode) { > > # Check if we should display a checkin message, based on the the item > # type of the checked in item >- my $itemtype = C4::ItemType->get( $biblio->{'itemtype'} ); >- if ( $itemtype->{'checkinmsg'} ) { >+ my $itemtype = Koha::ItemTypes->find( $biblio->{'itemtype'} ); >+ if ( $itemtype->checkinmsg ) { > $template->param( >- checkinmsg => $itemtype->{'checkinmsg'}, >- checkinmsgtype => $itemtype->{'checkinmsgtype'}, >+ checkinmsg => $itemtype->checkinmsg, >+ checkinmsgtype => $itemtype->checkinmsgtype, > ); > } > > # make sure return branch respects home branch circulation rules, default to homebranch >- my $hbr = GetBranchItemRule($biblio->{'homebranch'}, $itemtype->{itemtype})->{'returnbranch'} || "homebranch"; >+ my $hbr = GetBranchItemRule($biblio->{'homebranch'}, $itemtype->itemtype)->{'returnbranch'} || "homebranch"; > my $returnbranch = $biblio->{$hbr} ; > > $template->param( >diff --git a/koha-tmpl/intranet-tmpl/prog/en/modules/admin/item_circulation_alerts.tt b/koha-tmpl/intranet-tmpl/prog/en/modules/admin/item_circulation_alerts.tt >index ad451e1..b55709c 100644 >--- a/koha-tmpl/intranet-tmpl/prog/en/modules/admin/item_circulation_alerts.tt >+++ b/koha-tmpl/intranet-tmpl/prog/en/modules/admin/item_circulation_alerts.tt >@@ -157,7 +157,7 @@ $(function(){ > <tr> > <th> </th> > [% FOREACH item_type IN item_types %] >- <th>[% item_type.br_description %]</th> >+ <th>[% item_type.description %]</th> > [% END %] > </tr> > </thead> >@@ -181,7 +181,7 @@ $(function(){ > <tr> > <th> </th> > [% FOREACH item_type IN item_types %] >- <th>[% item_type.br_description %]</th> >+ <th>[% item_type.description %]</th> > [% END %] > </tr> > </thead> >diff --git a/t/db_dependent/HoldsQueue.t b/t/db_dependent/HoldsQueue.t >index fb26c11..5d8ef6e 100755 >--- a/t/db_dependent/HoldsQueue.t >+++ b/t/db_dependent/HoldsQueue.t >@@ -15,12 +15,13 @@ use Data::Dumper; > use Test::More tests => 23; > > use C4::Branch; >-use C4::ItemType; > use C4::Members; > use Koha::Database; > > use t::lib::TestBuilder; > >+use Koha::ItemTypes; >+ > BEGIN { > use FindBin; > use lib $FindBin::Bin; >@@ -60,9 +61,10 @@ my $borrower_branchcode = $borrower->{branchcode}; > my @branchcodes = ( $library1->{branchcode}, $library2->{branchcode}, $library3->{branchcode} ); > my @other_branches = ( $library2->{branchcode}, $library3->{branchcode} ); > my $least_cost_branch_code = pop @other_branches; >-my @item_types = C4::ItemType->all; >-my $itemtype = grep { $_->{notforloan} == 1 } @item_types >- or BAIL_OUT("No adequate itemtype"); >+my $itemtype = Koha::ItemTypes->search({ notforloan => 1 })->next; >+$itemtype or BAIL_OUT("No adequate itemtype"); >+ >+# FIXME Should be $itemtype = $itemtype->itemtype > > #Set up the stage > # Sysprefs and cost matrix >@@ -178,7 +180,7 @@ $dbh->do("DELETE FROM default_circ_rules"); > > C4::Context->set_preference('UseTransportCostMatrix', 0); > >-( $itemtype ) = @{ $dbh->selectrow_arrayref("SELECT itemtype FROM itemtypes LIMIT 1") }; >+$itemtype = Koha::ItemTypes->search->next->itemtype; > > $library1 = $builder->build({ > source => 'Branch', >@@ -308,7 +310,7 @@ is( @$holds_queue, 3, "Holds queue filling correct number for holds for default > #warn "HOLDS QUEUE: " . Data::Dumper::Dumper( $holds_queue ); > > # Bug 14297 >-$itemtype = $item_types[0]->{itemtype}; >+$itemtype = Koha::ItemTypes->search->next->itemtype; > $borrowernumber = $borrower3->{borrowernumber}; > my $library_A = $library1->{branchcode}; > my $library_B = $library2->{branchcode}; >@@ -365,7 +367,7 @@ is( @$holds_queue, 1, "Bug 14297 - Holds Queue building ignoring holds where pic > # End Bug 14297 > > # Bug 15062 >-$itemtype = $item_types[0]->{itemtype}; >+$itemtype = Koha::ItemTypes->search->next->itemtype; > $borrowernumber = $borrower2->{borrowernumber}; > $library_A = $library1->{branchcode}; > $library_B = $library2->{branchcode}; >-- >2.1.0
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 14828
:
42566
|
42567
|
42568
|
42569
|
45748
|
45749
|
45750
|
45751
|
45769
|
45771
|
45772
|
45773
|
45774
|
46731
|
46732
|
46733
|
46734
|
46735
|
47341
|
47342
|
47343
|
47344
|
47345