Bugzilla – Attachment 107131 Details for
Bug 25951
Koha::Objects using the DBIx::Class relationships in Koha::Hold and Koha::Item
Home
|
New
|
Browse
|
Search
|
[?]
|
Reports
|
Help
|
New Account
|
Log In
[x]
|
Forgot Password
Login:
[x]
[patch]
Bug 25951: Koha::Objects using the DBIx::Class relationships in Koha::Hold and Koha::Item
Bug-25951-KohaObjects-using-the-DBIxClass-relation.patch (text/plain), 8.15 KB, created by
Nicolas Legrand
on 2020-07-21 09:12:34 UTC
(
hide
)
Description:
Bug 25951: Koha::Objects using the DBIx::Class relationships in Koha::Hold and Koha::Item
Filename:
MIME Type:
Creator:
Nicolas Legrand
Created:
2020-07-21 09:12:34 UTC
Size:
8.15 KB
patch
obsolete
>From 1c7d133c6a5b87519f54d17cccc35c07e173f959 Mon Sep 17 00:00:00 2001 >From: Nicolas Legrand <nicolas.legrand@bulac.fr> >Date: Tue, 21 Jul 2020 11:09:00 +0200 >Subject: [PATCH] Bug 25951: Koha::Objects using the DBIx::Class relationships > in Koha::Hold and Koha::Item > >Those changes focus on intranet pages /reserve/request.pl, >circ/waitingreserves.pl and opac page koha/opac-user.pl. > >Test plan: > >1. Apply the tests patch and do its test plan >2. apply this patch >3. rerun `prove t/db_dependent/Koha/Item/RelatedObjects.t ; prove >t/db_dependent/Koha/Holds.pm`, all should be ok >4. make a hold on a checkouted item and check it in. It should be in >waiting reserves now. >5. go have a look to /reserve/request.pl, circ/waitingreserves.pl, >koha/opac-user.pl (while logged as the user having the hold) pages. >6. it should be errorless, you should see the library names and the >forms should prompt the correct branchcode. >--- > Koha/Hold.pm | 28 ++++++++++------------ > Koha/Item.pm | 18 +++++++------- > .../intranet-tmpl/prog/en/includes/holds_table.inc | 2 +- > .../prog/en/includes/waiting_holds.inc | 6 ++--- > .../bootstrap/en/includes/holds-table.inc | 6 ++--- > 5 files changed, 28 insertions(+), 32 deletions(-) > >diff --git a/Koha/Hold.pm b/Koha/Hold.pm >index 8969e32..70426ef 100644 >--- a/Koha/Hold.pm >+++ b/Koha/Hold.pm >@@ -298,11 +298,10 @@ Returns the related Koha::Item object for this Hold > =cut > > sub item { >- my ($self) = @_; >- >- $self->{_item} ||= Koha::Items->find( $self->itemnumber() ); >- >- return $self->{_item}; >+ my $self = shift; >+ my $item_rs = $self->_result->item; >+ return unless $item_rs; >+ return Koha::Item->_new_from_dbic($item_rs); > } > > =head3 branch >@@ -311,12 +310,12 @@ Returns the related Koha::Library object for this Hold > > =cut > >+# FIXME Should be renamed with ->library > sub branch { >- my ($self) = @_; >- >- $self->{_branch} ||= Koha::Libraries->find( $self->branchcode() ); >- >- return $self->{_branch}; >+ my $self = shift; >+ my $branch_rs = $self->_result->branchcode; >+ return unless $branch_rs; >+ return Koha::Library->_new_from_dbic($branch_rs); > } > > =head3 borrower >@@ -327,11 +326,10 @@ Returns the related Koha::Patron object for this Hold > > # FIXME Should be renamed with ->patron > sub borrower { >- my ($self) = @_; >- >- $self->{_borrower} ||= Koha::Patrons->find( $self->borrowernumber() ); >- >- return $self->{_borrower}; >+ my $self = shift; >+ my $patron_rs = $self->_result->borrowernumber; >+ return unless $patron_rs; >+ return Koha::Patron->_new_from_dbic($patron_rs); > } > > =head3 is_suspended >diff --git a/Koha/Item.pm b/Koha/Item.pm >index 9560a56..2ecbb8f 100644 >--- a/Koha/Item.pm >+++ b/Koha/Item.pm >@@ -301,11 +301,10 @@ sub effective_itemtype { > =cut > > sub home_branch { >- my ($self) = @_; >- >- $self->{_home_branch} ||= Koha::Libraries->find( $self->homebranch() ); >- >- return $self->{_home_branch}; >+ my $self = shift; >+ my $home_branch_rs = $self->_result->homebranch; >+ return unless $home_branch_rs; >+ return Koha::Library->_new_from_dbic($home_branch_rs); > } > > =head3 holding_branch >@@ -313,11 +312,10 @@ sub home_branch { > =cut > > sub holding_branch { >- my ($self) = @_; >- >- $self->{_holding_branch} ||= Koha::Libraries->find( $self->holdingbranch() ); >- >- return $self->{_holding_branch}; >+ my $self = shift; >+ my $holding_branch_rs = $self->_result->holdingbranch; >+ return unless $holding_branch_rs; >+ return Koha::Library->_new_from_dbic($holding_branch_rs); > } > > =head3 biblio >diff --git a/koha-tmpl/intranet-tmpl/prog/en/includes/holds_table.inc b/koha-tmpl/intranet-tmpl/prog/en/includes/holds_table.inc >index 600977a..2046152 100644 >--- a/koha-tmpl/intranet-tmpl/prog/en/includes/holds_table.inc >+++ b/koha-tmpl/intranet-tmpl/prog/en/includes/holds_table.inc >@@ -128,7 +128,7 @@ > [% END %] > [% ELSE %] > [% IF Koha.Preference('IndependentBranches') && Branches.all().size == 1 %] >- [% Branches.GetName(hold.branchcode) | html %] <input type="hidden" name="pickup" value="[% hold.branchcode | html %]" /> >+ [% hold.branch.branchname | html %] <input type="hidden" name="pickup" value="[% hold.branchcode | html %]" /> > [% ELSE %] > <select name="pickup"> > [% PROCESS options_for_libraries libraries => Branches.pickup_locations( { search_params => { item => hold.itemnumber, biblio => hold.biblionumber, patron => hold.patron }, selected => hold.branchcode }) %] >diff --git a/koha-tmpl/intranet-tmpl/prog/en/includes/waiting_holds.inc b/koha-tmpl/intranet-tmpl/prog/en/includes/waiting_holds.inc >index e445ace..9eeeac5 100644 >--- a/koha-tmpl/intranet-tmpl/prog/en/includes/waiting_holds.inc >+++ b/koha-tmpl/intranet-tmpl/prog/en/includes/waiting_holds.inc >@@ -37,8 +37,8 @@ > [% reserveloo.borrower.first_valid_email_address | html %]</a></span> > [% END %] > </td> >- <td>[% Branches.GetName( reserveloo.item.homebranch ) | html %]</td> >- <td>[% Branches.GetName( reserveloo.item.holdingbranch ) | html %]</td> >+ <td>[% reserveloo.item.home_branch.branchname | html %]</td> >+ <td>[% reserveloo.item.holding_branch.branchname | html %]</td> > <td>[% AuthorisedValues.GetByCode('LOC', reserveloo.item.location) | html %]</td> > <td>[% reserveloo.item.itemcallnumber | html %]</td> > <td>[% reserveloo.item.copynumber | html %]</td> >@@ -51,7 +51,7 @@ > <input type="hidden" name="tbr" value="[% reserveloo.item.homebranch | html %]" /> > <input type="hidden" name="tab" value="[% tab | html %]"> > [% IF ( reserveloo.item.homebranch != reserveloo.item.holdingbranch ) %] >- <button type="submit" class="btn btn-default btn-xs"><i class="fa fa-remove"></i> Cancel hold and return to: [% Branches.GetName( reserveloo.item.homebranch ) | html %]</button> >+ <button type="submit" class="btn btn-default btn-xs"><i class="fa fa-remove"></i> Cancel hold and return to: [% reserveloo.item.home_branch.branchname | html %]</button> > [% ELSE %] > <button type="submit" class="btn btn-default btn-xs"><i class="fa fa-remove"></i> Cancel hold</button> > [% END %] >diff --git a/koha-tmpl/opac-tmpl/bootstrap/en/includes/holds-table.inc b/koha-tmpl/opac-tmpl/bootstrap/en/includes/holds-table.inc >index 610c968..d191163 100644 >--- a/koha-tmpl/opac-tmpl/bootstrap/en/includes/holds-table.inc >+++ b/koha-tmpl/opac-tmpl/bootstrap/en/includes/holds-table.inc >@@ -112,12 +112,12 @@ > until [% HOLD.expirationdate | $KohaDates %] > [% END %] > [% END %] >- <input type="hidden" name="pickup" value="[% HOLD.branchcode | html %]" /> >+ <input type="hidden" name="pickup" value="[% HOLD.branch.branchcode | html %]" /> > [% ELSE %] >- Item waiting to be pulled from <strong> [% Branches.GetName( HOLD.branchcode ) | html %]</strong> >+ Item waiting to be pulled from <strong> [% HOLD.branch.branchname | html %]</strong> > [% END %] > [% ELSE %] >- Item in transit to <strong> [% Branches.GetName( HOLD.branchcode ) | html %]</strong> <input type="hidden" name="pickup" value="[% HOLD.branchcode | html %]" /> >+ Item in transit to <strong> [% HOLD.branch.branchname | html %]</strong> <input type="hidden" name="pickup" value="[% HOLD.branchcode | html %]" /> > [% END %] > [% ELSE %] > [% IF ( HOLD.is_in_transit ) %] >-- >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 25951
:
106649
|
107129
|
107130
| 107131