Bugzilla – Attachment 84928 Details for
Bug 20581
Allow manual selection of custom ILL request statuses
Home
|
New
|
Browse
|
Search
|
[?]
|
Reports
|
Help
|
New Account
|
Log In
[x]
|
Forgot Password
Login:
[x]
[patch]
Bug 20581: (follow-up) Overload status_alias
Bug-20581-follow-up-Overload-statusalias.patch (text/plain), 4.23 KB, created by
Katrin Fischer
on 2019-02-09 21:53:47 UTC
(
hide
)
Description:
Bug 20581: (follow-up) Overload status_alias
Filename:
MIME Type:
Creator:
Katrin Fischer
Created:
2019-02-09 21:53:47 UTC
Size:
4.23 KB
patch
obsolete
>From d7705ca57c64eb93fa0322270393c4e4a382bbd6 Mon Sep 17 00:00:00 2001 >From: Andrew Isherwood <andrew.isherwood@ptfs-europe.com> >Date: Wed, 6 Feb 2019 12:54:30 +0000 >Subject: [PATCH] Bug 20581: (follow-up) Overload status_alias > >We need Koha::Illrequest->status_alias to return the correct authorised value. >Since the foreign key uses a non-unique column, we need to take into >account the authorised value category too. > >This patch overloads status_alias with some additional logic that >considers the request's branch and the authorised value category to >attempt to return the correct value. > >The same logic is applied to the custom statusalias method, which >returns the entire AuthorisedValue object > >Signed-off-by: Katrin Fischer <katrin.fischer.83@web.de> >--- > Koha/Illrequest.pm | 65 +++++++++++++++++++++++++++++++++++++++++++++++++----- > 1 file changed, 60 insertions(+), 5 deletions(-) > >diff --git a/Koha/Illrequest.pm b/Koha/Illrequest.pm >index 49602d325e..6c090f5c64 100644 >--- a/Koha/Illrequest.pm >+++ b/Koha/Illrequest.pm >@@ -33,6 +33,7 @@ use Koha::Illcomments; > use Koha::Illrequestattributes; > use Koha::AuthorisedValue; > use Koha::Patron; >+use Koha::AuthorisedValues; > > use base qw(Koha::Object); > >@@ -115,16 +116,23 @@ available for request. > my $statusalias = $request->statusalias; > > Returns a request's status alias, as a Koha::AuthorisedValue instance >-or implicit undef >+or implicit undef. This is distinct from status_alias, which only returns >+the value in the status_alias column, this method returns the entire >+AuthorisedValue object > > =cut > > sub statusalias { > my ( $self ) = @_; > return unless $self->status_alias; >- return Koha::AuthorisedValue->_new_from_dbic( >- scalar $self->_result->status_alias >- ); >+ # We can't know which result is the right one if there are multiple >+ # ILLSTATUS authorised values with the same authorised_value column value >+ # so we just use the first >+ return Koha::AuthorisedValues->search({ >+ branchcode => $self->branchcode, >+ category => 'ILLSTATUS', >+ authorised_value => $self->SUPER::status_alias >+ })->next; > } > > =head3 illrequestattributes >@@ -160,6 +168,46 @@ sub patron { > ); > } > >+=head3 status_alias >+Overloaded getter/setter for status_alias, >+that only returns authorised values from the >+correct category >+ >+=cut >+ >+sub status_alias { >+ my ($self, $newval) = @_; >+ if ($newval) { >+ # This is hackery to enable us to undefine >+ # status_alias, since we need to have an overloaded >+ # status_alias method to get us around the problem described >+ # here: >+ # https://bugs.koha-community.org/bugzilla3/show_bug.cgi?id=20581#c156 >+ # We need a way of accepting implied undef, so we can nullify >+ # the status_alias column, when called from $self->status >+ my $val = $newval == -1 ? undef : $newval; >+ my $newval = $self->SUPER::status_alias($newval); >+ if ($newval) { >+ return $newval; >+ } else { >+ return; >+ } >+ } >+ # We can't know which result is the right one if there are multiple >+ # ILLSTATUS authorised values with the same authorised_value column value >+ # so we just use the first >+ my $alias = Koha::AuthorisedValues->search({ >+ branchcode => $self->branchcode, >+ category => 'ILLSTATUS', >+ authorised_value => $self->SUPER::status_alias >+ })->next; >+ if ($alias) { >+ return $alias->authorised_value; >+ } else { >+ return; >+ } >+} >+ > =head3 status > > Overloaded getter/setter for request status, >@@ -170,7 +218,14 @@ also nullifies status_alias > sub status { > my ( $self, $newval) = @_; > if ($newval) { >- $self->status_alias(undef); >+ # This is hackery to enable us to undefine >+ # status_alias, since we need to have an overloaded >+ # status_alias method to get us around the problem described >+ # here: >+ # https://bugs.koha-community.org/bugzilla3/show_bug.cgi?id=20581#c156 >+ # We need a way of passing implied undef to nullify status_alias >+ # so we pass -1, which is special cased in the overloaded setter >+ $self->status_alias(-1); > return $self->SUPER::status($newval); > } > return $self->SUPER::status; >-- >2.11.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 20581
:
74323
|
74324
|
74325
|
74326
|
74327
|
74362
|
75333
|
75334
|
75810
|
77819
|
77820
|
77821
|
77822
|
77823
|
77824
|
77825
|
77826
|
78376
|
78377
|
78378
|
78379
|
78380
|
78381
|
78382
|
78383
|
78384
|
78431
|
78515
|
78516
|
78517
|
78518
|
78519
|
78520
|
78521
|
78522
|
78523
|
80279
|
80280
|
80281
|
80282
|
80283
|
80284
|
80285
|
80286
|
80474
|
80475
|
80501
|
80503
|
80505
|
80598
|
80599
|
80600
|
82063
|
82064
|
82065
|
82066
|
82067
|
82068
|
82069
|
82070
|
82071
|
82072
|
82073
|
82074
|
82075
|
82076
|
82443
|
82444
|
82445
|
82446
|
82447
|
82448
|
82449
|
82450
|
82451
|
82452
|
82453
|
82454
|
82455
|
82456
|
82457
|
82458
|
82459
|
82460
|
82461
|
82462
|
82463
|
82464
|
82465
|
82466
|
82467
|
82468
|
82472
|
82483
|
82484
|
82485
|
82486
|
82487
|
82488
|
82489
|
82490
|
82491
|
82492
|
82493
|
82494
|
82495
|
82496
|
82733
|
84202
|
84404
|
84768
|
84770
|
84771
|
84772
|
84773
|
84774
|
84775
|
84776
|
84777
|
84778
|
84779
|
84780
|
84781
|
84782
|
84783
|
84784
|
84785
|
84791
|
84814
|
84818
|
84819
|
84844
|
84911
|
84912
|
84913
|
84914
|
84915
|
84916
|
84917
|
84918
|
84919
|
84920
|
84921
|
84922
|
84923
|
84924
|
84925
|
84926
|
84927
|
84928
|
84929
|
84930
|
84931
|
84964
|
85075
|
85076
|
85077
|
85078
|
85079
|
85080
|
85081
|
85082
|
85083
|
85084
|
85085
|
85086
|
85087
|
85088
|
85089
|
85090
|
85091
|
85092
|
85093
|
85094
|
85095
|
85096