Bugzilla – Attachment 68874 Details for
Bug 7317
Add an Interlibrary Loan Module to Circulation and OPAC
Home
|
New
|
Browse
|
Search
|
[?]
|
Reports
|
Help
|
New Account
|
Log In
[x]
|
Forgot Password
Login:
[x]
[patch]
Bug 7317: Handle backend absense more gracefuly
Bug-7317-Handle-backend-absense-more-gracefuly.patch (text/plain), 7.00 KB, created by
Tomás Cohen Arazi (tcohen)
on 2017-10-31 19:43:36 UTC
(
hide
)
Description:
Bug 7317: Handle backend absense more gracefuly
Filename:
MIME Type:
Creator:
Tomás Cohen Arazi (tcohen)
Created:
2017-10-31 19:43:36 UTC
Size:
7.00 KB
patch
obsolete
>From 7dafa73f01a7a03392d716a042aa962c7a5b7986 Mon Sep 17 00:00:00 2001 >From: Tomas Cohen Arazi <tomascohen@theke.io> >Date: Tue, 31 Oct 2017 16:28:53 -0300 >Subject: [PATCH] Bug 7317: Handle backend absense more gracefuly > >5/ This patch is WIP, it makes Koha::Illrequest->load_backend raise an exception >if the passed backend is invalid. This way we will catch more errors introduced. > >The patch also disables the 'New Ill request' when no backends are available. Gets >rid of a related warning. > >TODO: Should add a noticeable warning on the UI, or a tooltip on the button. >TODO: add a couple tests for the exception > >4/ This patch fixes the path for the checkboxes jquery plugin, and removes the include >for tablesorter, as this implementation uses Datatables. This is obviously code for older >Koha, ported to master. > >3/ I know it doesn't look right, but am not sure how to display. This is the usual empty >datatable display we have everywhere in Koha. > >2/ We could fix it with a proper IDE, I use Komodo and refactoring code is pretty straigh-forward. >Worth a separate bug report. > >1/ That TODO is misleading. It refers to their own migration from a different design. I checked this >code and cannot find occurences of ->status with that annotation. I think this relates to backends code. > >Signed-off-by: Tomas Cohen Arazi <tomascohen@theke.io> >--- > Koha/Exceptions/Ill.pm | 16 ++++++++++++++++ > Koha/Illrequest.pm | 12 ++++++++++-- > ill/ill-requests.pl | 13 +++++++------ > koha-tmpl/intranet-tmpl/prog/en/includes/ill-toolbar.inc | 10 ++++++++-- > .../intranet-tmpl/prog/en/modules/ill/ill-requests.tt | 3 +-- > 5 files changed, 42 insertions(+), 12 deletions(-) > create mode 100644 Koha/Exceptions/Ill.pm > >diff --git a/Koha/Exceptions/Ill.pm b/Koha/Exceptions/Ill.pm >new file mode 100644 >index 0000000..38643d4 >--- /dev/null >+++ b/Koha/Exceptions/Ill.pm >@@ -0,0 +1,16 @@ >+package Koha::Exceptions::Ill; >+ >+use Modern::Perl; >+ >+use Exception::Class ( >+ >+ 'Koha::Exceptions::Ill' => { >+ description => 'Something went wrong!', >+ }, >+ 'Koha::Exceptions::Ill::InvalidBackendId' => { >+ isa => 'Koha::Exceptions::Ill', >+ description => "Invalid backend name required", >+ } >+); >+ >+1; >diff --git a/Koha/Illrequest.pm b/Koha/Illrequest.pm >index 5adecb5..5435bf5 100644 >--- a/Koha/Illrequest.pm >+++ b/Koha/Illrequest.pm >@@ -18,16 +18,18 @@ package Koha::Illrequest; > # Koha; if not, write to the Free Software Foundation, Inc., 51 Franklin > # Street, Fifth Floor, Boston, MA 02110-1301 USA. > >+use Modern::Perl; >+ > use Clone 'clone'; > use File::Basename qw/basename/; > use Koha::Database; > use Koha::Email; >+use Koha::Exceptions::Ill; > use Koha::Illrequest; > use Koha::Illrequestattributes; > use Koha::Patron; > use Mail::Sendmail; > use Try::Tiny; >-use Modern::Perl; > > use base qw(Koha::Object); > >@@ -138,14 +140,20 @@ sub load_backend { > > my @raw = qw/Koha Illbackends/; # Base Path > >+ unless ( defined $backend_id && $backend_id ne '' ) { >+ Koha::Exceptions::Ill::InvalidBackendId->throw( >+ "An invalid backend ID was requested ('')"); >+ } >+ > my $backend_name = $backend_id || $self->backend; >- my $location = join "/", @raw, $backend_name, "Base.pm"; # File to load >+ my $location = join "/", @raw, $backend_name, "Base.pm"; # File to load > my $backend_class = join "::", @raw, $backend_name, "Base"; # Package name > require $location; > $self->{_my_backend} = $backend_class->new({ config => $self->_config }); > return $self; > } > >+ > =head3 _backend > > my $backend = $abstract->_backend($new_backend); >diff --git a/ill/ill-requests.pl b/ill/ill-requests.pl >index f6572e4..e316acd 100755 >--- a/ill/ill-requests.pl >+++ b/ill/ill-requests.pl >@@ -224,14 +224,15 @@ if ( $op eq 'illview' ) { > } > > # Get a list of backends >-my $ir = Koha::Illrequest->new; >+my $available_backends = Koha::Illrequest->new->available_backends; > > $template->param( >- backends => $ir->available_backends, >- media => [ "Book", "Article", "Journal" ], >- query_type => $op, >- branches => Koha::Libraries->search->unblessed, >- here_link => "/cgi-bin/koha/ill/ill-requests.pl" >+ backends_available => ( scalar $available_backends > 0 ), >+ backends => $available_backends, >+ media => [ "Book", "Article", "Journal" ], >+ query_type => $op, >+ branches => Koha::Libraries->search, >+ here_link => "/cgi-bin/koha/ill/ill-requests.pl" > ); > > output_html_with_http_headers( $cgi, $cookie, $template->output ); >diff --git a/koha-tmpl/intranet-tmpl/prog/en/includes/ill-toolbar.inc b/koha-tmpl/intranet-tmpl/prog/en/includes/ill-toolbar.inc >index 3f541d9..717d12b 100644 >--- a/koha-tmpl/intranet-tmpl/prog/en/includes/ill-toolbar.inc >+++ b/koha-tmpl/intranet-tmpl/prog/en/includes/ill-toolbar.inc >@@ -1,7 +1,8 @@ > [% USE Koha %] > [% IF Koha.Preference('ILLModule ') %] > <div id="toolbar" class="btn-toolbar"> >- [% IF backends.size > 1 %] >+ [% IF available_backends %] >+ [% IF backends.size > 1 %] > <div class="dropdown btn-group"> > <button class="btn btn-sm btn-default dropdown-toggle" type="button" id="ill-backend-dropdown" data-toggle="dropdown" aria-haspopup="true" aria-expanded="true"> > <i class="fa fa-plus"></i> New ILL request <span class="caret"></span> >@@ -12,10 +13,15 @@ > [% END %] > </ul> > </div> >- [% ELSE %] >+ [% ELSE %] > <a id="ill-new" class="btn btn-sm btn-default" href="/cgi-bin/koha/ill/ill-requests.pl?method=create&backend=[% backends.0 %]"> > <i class="fa fa-plus"></i> New ILL request > </a> >+ [% END %] >+ [% ELSE %] >+ <a id="ill-new" class="btn btn-sm btn-default disabled" href=""> >+ <i class="fa fa-plus"></i> New ILL request >+ </a> > [% END %] > <a id="ill-list" class="btn btn-sm btn-default btn-group" href="/cgi-bin/koha/ill/ill-requests.pl"> > <i class="fa fa-list"></i> List requests >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 96943c1..6a32d5e 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 >@@ -4,8 +4,7 @@ > [% INCLUDE 'doc-head-open.inc' %] > <title>Koha › ILL requests ›</title> > [% INCLUDE 'doc-head-close.inc' %] >-<script type="text/javascript" src="[% themelang %]/lib/jquery/plugins/jquery.tablesorter.min.js"></script> >-<script type="text/javascript" src="[% themelang %]/lib/jquery/plugins/jquery.checkboxes.min.js"></script> >+<script type="text/javascript" src="[% interface %]/lib/jquery/plugins/jquery.checkboxes.min.js"></script> > <link rel="stylesheet" type="text/css" href="[% interface %]/[% theme %]/css/datatables.css"> > [% INCLUDE 'datatables.inc' %] > <script type="text/javascript"> >-- >2.7.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 7317
:
59893
|
59894
|
59895
|
59920
|
60485
|
60486
|
60487
|
60488
|
63081
|
63082
|
63083
|
63084
|
63085
|
63086
|
63087
|
63088
|
63089
|
63090
|
63113
|
63175
|
63176
|
63354
|
63421
|
63472
|
63475
|
65469
|
65470
|
65471
|
65472
|
65473
|
65474
|
65475
|
65476
|
66266
|
67242
|
67243
|
67244
|
67245
|
67246
|
67247
|
67248
|
67249
|
67250
|
67251
|
67252
|
67253
|
67254
|
67255
|
67256
|
67257
|
67258
|
67259
|
67260
|
67261
|
67262
|
67263
|
67264
|
67281
|
67282
|
67283
|
67284
|
67285
|
67286
|
67287
|
67288
|
67289
|
67290
|
67291
|
67292
|
67293
|
67294
|
67295
|
67296
|
67297
|
67298
|
67299
|
67300
|
67301
|
67302
|
67303
|
68185
|
68186
|
68328
|
68391
|
68406
|
68407
|
68408
|
68409
|
68418
|
68444
|
68445
|
68483
|
68484
|
68485
|
68487
|
68516
|
68517
|
68518
|
68519
|
68520
|
68521
|
68522
|
68523
|
68524
|
68525
|
68542
|
68543
|
68544
|
68545
|
68546
|
68547
|
68548
|
68549
|
68550
|
68551
|
68552
|
68558
|
68559
|
68560
|
68561
|
68562
|
68563
|
68564
|
68565
|
68566
|
68567
|
68858
|
68874
|
68877
|
68878
|
68885
|
68886
|
68921
|
68922
|
68926
|
68927
|
68928
|
68929
|
68931
|
68932
|
68933
|
68988
|
68989
|
68999
|
69000
|
69006
|
69008
|
69009
|
69012
|
69014
|
69044
|
69045
|
69046
|
69056
|
69059
|
69060
|
69061
|
69063
|
69064
|
69065
|
69066
|
69069
|
69070
|
69071
|
69074