Bugzilla – Attachment 42531 Details for
Bug 14819
Add missing DBIx::Class relationships - biblio<->biblioitem<->item
Home
|
New
|
Browse
|
Search
|
[?]
|
Reports
|
Help
|
New Account
|
Log In
[x]
|
Forgot Password
Login:
[x]
[patch]
Bug 14819: Add missing DBIx::Class relationships - biblio<->biblioitem<->item
Bug-14819-Add-missing-DBIxClass-relationships---bi.patch (text/plain), 4.34 KB, created by
Jonathan Druart
on 2015-09-14 16:08:32 UTC
(
hide
)
Description:
Bug 14819: Add missing DBIx::Class relationships - biblio<->biblioitem<->item
Filename:
MIME Type:
Creator:
Jonathan Druart
Created:
2015-09-14 16:08:32 UTC
Size:
4.34 KB
patch
obsolete
>From 1b4e7ebf9ea2e59166547895a3a3955d0d50d634 Mon Sep 17 00:00:00 2001 >From: Jonathan Druart <jonathan.druart@bugs.koha-community.org> >Date: Mon, 14 Sep 2015 17:05:53 +0100 >Subject: [PATCH] Bug 14819: Add missing DBIx::Class relationships - > biblio<->biblioitem<->item > >To access the biblio from an item, we should not use the >biblioitemnumber relationship autogenerated by >DBIx::Class::Schema::Loader but create our own one. > >Test plan: >Confirm the tests pass and that there is no regression on bug 14726. >--- > Koha/Item.pm | 9 +++++++ > Koha/Schema/Result/Biblioitem.pm | 2 +- > Koha/Schema/Result/Item.pm | 2 ++ > .../prog/en/modules/circ/circulation.tt | 2 +- > t/db_dependent/Schema.t | 31 ++++++++++++++++++++++ > 5 files changed, 44 insertions(+), 2 deletions(-) > create mode 100644 t/db_dependent/Schema.t > >diff --git a/Koha/Item.pm b/Koha/Item.pm >index 2dcccfb..4d311f6 100644 >--- a/Koha/Item.pm >+++ b/Koha/Item.pm >@@ -37,6 +37,15 @@ Koha::Item - Koha Item object class > > =cut > >+=head3 biblioitem >+ >+=cut >+ >+sub biblioitem { >+ my ( $self ) = @_; >+ return $self->_result->biblioitem; >+} >+ > =head3 effective_itemtype > > Returns the itemtype for the item based on whether item level itemtypes are set or not. >diff --git a/Koha/Schema/Result/Biblioitem.pm b/Koha/Schema/Result/Biblioitem.pm >index 874f1d2..a9b926a 100644 >--- a/Koha/Schema/Result/Biblioitem.pm >+++ b/Koha/Schema/Result/Biblioitem.pm >@@ -344,6 +344,6 @@ __PACKAGE__->has_many( > # Created by DBIx::Class::Schema::Loader v0.07039 @ 2015-02-24 14:19:57 > # DO NOT MODIFY THIS OR ANYTHING ABOVE! md5sum:A/4lKYlKWWd8TcMVzMRtCg > >+__PACKAGE__->belongs_to( biblio => "Koha::Schema::Result::Biblio", "biblionumber" ); > >-# You can replace this text with custom content, and it will be preserved on regeneration > 1; >diff --git a/Koha/Schema/Result/Item.pm b/Koha/Schema/Result/Item.pm >index c342f46..2f764a3 100644 >--- a/Koha/Schema/Result/Item.pm >+++ b/Koha/Schema/Result/Item.pm >@@ -619,6 +619,8 @@ __PACKAGE__->might_have( > # Created by DBIx::Class::Schema::Loader v0.07039 @ 2015-04-23 12:42:12 > # DO NOT MODIFY THIS OR ANYTHING ABOVE! md5sum:urSpNt7LBda4T5Plhi6cPw > >+__PACKAGE__->belongs_to( biblioitem => "Koha::Schema::Result::Biblioitem", "biblioitemnumber" ); >+ > sub effective_itemtype { > my ( $self ) = @_; > >diff --git a/koha-tmpl/intranet-tmpl/prog/en/modules/circ/circulation.tt b/koha-tmpl/intranet-tmpl/prog/en/modules/circ/circulation.tt >index 6d9e5ad..1b7558a 100644 >--- a/koha-tmpl/intranet-tmpl/prog/en/modules/circ/circulation.tt >+++ b/koha-tmpl/intranet-tmpl/prog/en/modules/circ/circulation.tt >@@ -675,7 +675,7 @@ No patron matched <span class="ex">[% message %]</span> > </fieldset> > [% IF ( issue ) %] > <div class="lastchecked"> >- <p><strong>Checked out: </strong>[% issue.item.biblioitemnumber.biblionumber.title %] ([% issue.item.barcode %]). Due on [% issue.date_due | $KohaDates %]</p> >+ <p><strong>Checked out: </strong>[% issue.item.biblioitem.biblio.title %] ([% issue.item.barcode %]). Due on [% issue.date_due | $KohaDates %]</p> > </div> > [% END %] > </form></div> >diff --git a/t/db_dependent/Schema.t b/t/db_dependent/Schema.t >new file mode 100644 >index 0000000..b4f0347 >--- /dev/null >+++ b/t/db_dependent/Schema.t >@@ -0,0 +1,31 @@ >+use Modern::Perl; >+use Test::More tests => 1; >+ >+use t::lib::TestBuilder; >+ >+use Koha::Biblios; >+use Koha::Items; >+ >+my $builder = t::lib::TestBuilder->new; >+ >+subtest 'item->biblioitem' => sub { >+ plan tests => 1; >+ >+ # NOTE This is a trick, if we want to populate the biblioitems table, we should not create a Biblio but a Biblioitem >+ my $biblio = $builder->build( { source => 'Biblioitem', } )->{_fk}{biblionumber}; >+ my $item1 = $builder->build( >+ { source => 'Item', >+ value => { biblionumber => $biblio->{biblionumber}, biblioitemnumber => $biblio->{biblionumber} }, >+ } >+ ); >+ my $item2 = $builder->build( >+ { source => 'Item', >+ value => { biblionumber => $biblio->{biblionumber}, biblioitemnumber => $biblio->{biblionumber} }, >+ } >+ ); >+ >+ my $biblio_object = Koha::Biblios->find( $biblio->{biblionumber} ); >+ my $item_object = Koha::Items->find( $item1->{itemnumber} ); >+ >+ is( $item_object->biblioitem->biblio->biblionumber, $biblio->{biblionumber} ); >+}; >-- >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 14819
:
42531
|
44093