Bugzilla – Attachment 157499 Details for
Bug 35106
ILL - Add patron autocomplete to 'Edit request' Patron ID input
Home
|
New
|
Browse
|
Search
|
[?]
|
Reports
|
Help
|
New Account
|
Log In
[x]
|
Forgot Password
Login:
[x]
[patch]
Bug 35106: Validate entered borrowernumber and biblio_id
Bug-35106-Validate-entered-borrowernumber-and-bibl.patch (text/plain), 5.08 KB, created by
Pedro Amorim
on 2023-10-20 08:39:06 UTC
(
hide
)
Description:
Bug 35106: Validate entered borrowernumber and biblio_id
Filename:
MIME Type:
Creator:
Pedro Amorim
Created:
2023-10-20 08:39:06 UTC
Size:
5.08 KB
patch
obsolete
>From 28a71af126d60f3777817356153a8c5f8ee548f0 Mon Sep 17 00:00:00 2001 >From: Pedro Amorim <pedro.amorim@ptfs-europe.com> >Date: Thu, 19 Oct 2023 10:21:04 +0000 >Subject: [PATCH] Bug 35106: Validate entered borrowernumber and biblio_id > >Following up from the test plan of the previous patch: >1) Edit the request again, input gibberish in the Patron ID e.g. 'asdasd' >2) Hit 'Submit' >3) Notice you get a 'The Patron ID you entered is invalid.' message. >4) Edit again, try to empty the input on the Patron ID, hit 'Submit'. >5) Notice it saves the patron as null, as expected > >Repeat the test plan, but now for the Bibliographic record ID, notice >the message 'The Bibliographic record ID you entered is invalid.' is >shown if a no biblio was found. >--- > ill/ill-requests.pl | 64 ++++++++++++------- > .../prog/en/modules/ill/ill-requests.tt | 9 ++- > 2 files changed, 48 insertions(+), 25 deletions(-) > >diff --git a/ill/ill-requests.pl b/ill/ill-requests.pl >index a668b25979..8902c2ac4a 100755 >--- a/ill/ill-requests.pl >+++ b/ill/ill-requests.pl >@@ -243,30 +243,46 @@ if ( $backends_available ) { > batches => $batches > ); > } else { >- # Commit: >- # Save the changes >- $request->borrowernumber($params->{borrowernumber}); >- $request->biblio_id($params->{biblio_id}); >- $request->batch_id($params->{batch_id}); >- $request->branchcode($params->{branchcode}); >- $request->price_paid($params->{price_paid}); >- $request->notesopac($params->{notesopac}); >- $request->notesstaff($params->{notesstaff}); >- my $alias = (length $params->{status_alias} > 0) ? >- $params->{status_alias} : >- "-1"; >- $request->status_alias($alias); >- $request->store; >- my $backend_result = { >- error => 0, >- status => '', >- message => '', >- method => 'edit_action', >- stage => 'commit', >- next => 'illlist', >- value => {} >- }; >- handle_commit_maybe($backend_result, $request); >+ my $valid_patron = Koha::Patrons->find( $params->{borrowernumber} ); >+ my $valid_biblio = Koha::Biblios->find( $params->{biblio_id} ); >+ >+ if ( $params->{borrowernumber} && !$valid_patron || $params->{biblio_id} && !$valid_biblio ){ >+ my $error_result = { >+ error => 1, >+ status => $valid_biblio ? 'invalid_patron' : 'invalid_biblio', >+ method => 'edit_action', >+ stage => 'init', >+ next => 'illview', >+ }; >+ $template->param( >+ whole => $error_result, >+ request => $request, >+ ); >+ }else{ >+ $request->borrowernumber( $params->{borrowernumber} ); >+ $request->biblio_id( $params->{biblio_id} ); >+ $request->batch_id( $params->{batch_id} ); >+ $request->branchcode( $params->{branchcode} ); >+ $request->price_paid( $params->{price_paid} ); >+ $request->notesopac( $params->{notesopac} ); >+ $request->notesstaff( $params->{notesstaff} ); >+ my $alias = >+ ( length $params->{status_alias} > 0 ) >+ ? $params->{status_alias} >+ : "-1"; >+ $request->status_alias($alias); >+ $request->store; >+ my $backend_result = { >+ error => 0, >+ status => '', >+ message => '', >+ method => 'edit_action', >+ stage => 'commit', >+ next => 'illlist', >+ value => {} >+ }; >+ handle_commit_maybe( $backend_result, $request ); >+ } > } > > } elsif ( $op eq 'moderate_action' ) { >diff --git a/koha-tmpl/intranet-tmpl/prog/en/modules/ill/ill-requests.tt b/koha-tmpl/intranet-tmpl/prog/en/modules/ill/ill-requests.tt >index cb55d907e3..d64dd54e1d 100644 >--- a/koha-tmpl/intranet-tmpl/prog/en/modules/ill/ill-requests.tt >+++ b/koha-tmpl/intranet-tmpl/prog/en/modules/ill/ill-requests.tt >@@ -131,7 +131,14 @@ > <!-- Dispatch on Status --> > <p>We encountered an error:</p> > <p> >- <pre>[% whole.message | html %] ([% whole.status | html %])</pre> >+ [% SWITCH whole.status %] >+ [% CASE 'invalid_patron' %] >+ <pre>The Patron ID you entered is invalid.</pre> >+ [% CASE 'invalid_biblio' %] >+ <pre>The Bibliographic record ID you entered is invalid.</pre> >+ [% CASE %] >+ <pre>[% whole.message | html %] ([% whole.status | html %])</pre> >+ [% END %] > </p> > [% END %] > >-- >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 35106
:
157421
|
157422
|
157498
|
157499
|
159934
|
159935
|
164258
|
164259
|
164260
|
165543
|
165544
|
165545