Bugzilla – Attachment 79986 Details for
Bug 21082
OverDrive authentication method no longer supported
Home
|
New
|
Browse
|
Search
|
[?]
|
Reports
|
Help
|
New Account
|
Log In
[x]
|
Forgot Password
Login:
[x]
[patch]
Bug 21082: Add new admin page for overdrive
Bug-21082-Add-new-admin-page-for-overdrive.patch (text/plain), 10.95 KB, created by
Chris Cormack
on 2018-10-05 00:00:53 UTC
(
hide
)
Description:
Bug 21082: Add new admin page for overdrive
Filename:
MIME Type:
Creator:
Chris Cormack
Created:
2018-10-05 00:00:53 UTC
Size:
10.95 KB
patch
obsolete
>From c3bc3a282910d6fda1e37b0f22871ce71167972d Mon Sep 17 00:00:00 2001 >From: Nick Clemens <nick@bywatersolutions.com> >Date: Tue, 17 Jul 2018 14:08:13 +0000 >Subject: [PATCH] Bug 21082: Add new admin page for overdrive > >The 'authname' field required for OverDrive can differ per branch. >This patch adds Koha Objects for dealing with OD info and submitting >authnames per branch. The description is left open so future branch info >can be added. > >To test: >1 - prove -v t/db_dependent/Koha/Library/OverDriveInfos.t >2 - visit cgi-bin/koha/admin/overdrive.pl >3 - Add some authnames for various branches >4 - Verify data saves correctly > >Signed-off-by: Sandy Allgood <sandy.allgood@citruslibraries.org> >Signed-off-by: Chris Cormack <chrisc@catalyst.net.nz> >--- > Koha/Library/OverDriveInfo.pm | 44 +++++++++++ > Koha/Library/OverDriveInfos.pm | 54 +++++++++++++ > admin/overdrive.pl | 75 +++++++++++++++++++ > .../prog/en/modules/admin/overdrive.tt | 65 ++++++++++++++++ > t/db_dependent/Koha/Library/OverDriveInfos.t | 55 ++++++++++++++ > 5 files changed, 293 insertions(+) > create mode 100644 Koha/Library/OverDriveInfo.pm > create mode 100644 Koha/Library/OverDriveInfos.pm > create mode 100755 admin/overdrive.pl > create mode 100644 koha-tmpl/intranet-tmpl/prog/en/modules/admin/overdrive.tt > create mode 100644 t/db_dependent/Koha/Library/OverDriveInfos.t > >diff --git a/Koha/Library/OverDriveInfo.pm b/Koha/Library/OverDriveInfo.pm >new file mode 100644 >index 0000000000..6717699235 >--- /dev/null >+++ b/Koha/Library/OverDriveInfo.pm >@@ -0,0 +1,44 @@ >+package Koha::Library::OverDriveInfo; >+ >+# This file is part of Koha. >+# >+# Koha is free software; you can redistribute it and/or modify it under the >+# terms of the GNU General Public License as published by the Free Software >+# Foundation; either version 3 of the License, or (at your option) any later >+# version. >+# >+# Koha is distributed in the hope that it will be useful, but WITHOUT ANY >+# WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR >+# A PARTICULAR PURPOSE. See the GNU General Public License for more details. >+# >+# You should have received a copy of the GNU General Public License along >+# with Koha; if not, write to the Free Software Foundation, Inc., >+# 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA. >+ >+use Modern::Perl; >+ >+use Carp; >+ >+use Koha::Database; >+ >+use base qw(Koha::Object); >+ >+=head1 NAME >+ >+Koha::Library::OverDriveInfo - Koha Library OverDrive Info Object class >+ >+=head1 API >+ >+=head2 Class Methods >+ >+=cut >+ >+=head3 _type >+ >+=cut >+ >+sub _type { >+ return 'BranchesOverdrive'; >+} >+ >+1; >diff --git a/Koha/Library/OverDriveInfos.pm b/Koha/Library/OverDriveInfos.pm >new file mode 100644 >index 0000000000..8edc7fb40b >--- /dev/null >+++ b/Koha/Library/OverDriveInfos.pm >@@ -0,0 +1,54 @@ >+package Koha::Library::OverDriveInfos; >+ >+# This file is part of Koha. >+# >+# Koha is free software; you can redistribute it and/or modify it under the >+# terms of the GNU General Public License as published by the Free Software >+# Foundation; either version 3 of the License, or (at your option) any later >+# version. >+# >+# Koha is distributed in the hope that it will be useful, but WITHOUT ANY >+# WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR >+# A PARTICULAR PURPOSE. See the GNU General Public License for more details. >+# >+# You should have received a copy of the GNU General Public License along >+# with Koha; if not, write to the Free Software Foundation, Inc., >+# 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA. >+ >+use Modern::Perl; >+ >+use Carp; >+ >+use Koha::Database; >+ >+use Koha::Library::OverDriveInfo; >+ >+use base qw(Koha::Objects); >+ >+=head1 NAME >+ >+Koha::Library::OverDriveInfos - Koha Library OverDrive info Object set class >+ >+=head1 API >+ >+=head2 Class Methods >+ >+=cut >+ >+=head3 type >+ >+=cut >+ >+=head3 object_class >+ >+=cut >+ >+sub _type { >+ return 'BranchesOverdrive'; >+} >+ >+sub object_class { >+ return 'Koha::Library::OverDriveInfo'; >+} >+ >+1; >diff --git a/admin/overdrive.pl b/admin/overdrive.pl >new file mode 100755 >index 0000000000..489bf0ad40 >--- /dev/null >+++ b/admin/overdrive.pl >@@ -0,0 +1,75 @@ >+#!/usr/bin/perl >+ >+# Copyright Koha Development Team >+# >+# This file is part of Koha. >+# >+# Koha is free software; you can redistribute it and/or modify it >+# under the terms of the GNU General Public License as published by >+# the Free Software Foundation; either version 3 of the License, or >+# (at your option) any later version. >+# >+# Koha is distributed in the hope that it will be useful, but >+# WITHOUT ANY WARRANTY; without even the implied warranty of >+# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the >+# GNU General Public License for more details. >+# >+# You should have received a copy of the GNU General Public License >+# along with Koha; if not, see <http://www.gnu.org/licenses>. >+ >+use Modern::Perl; >+use CGI qw ( -utf8 ); >+use C4::Auth; >+use C4::Context; >+use C4::Output; >+ >+use Koha::Libraries; >+use Koha::Library::OverDriveInfos; >+ >+my $input = CGI->new; >+my @branchcodes = $input->multi_param('branchcode'); >+my @authnames = $input->multi_param('authname'); >+my $op = $input->param('op'); >+my @messages; >+ >+our ( $template, $loggedinuser, $cookie ) = get_template_and_user( >+ { template_name => 'admin/overdrive.tt', >+ query => $input, >+ type => 'intranet', >+ authnotrequired => 0, >+ flagsrequired => { parameters => 'parameters_remaining_permissions' }, >+ } >+); >+ >+if ( $op && $op eq 'update' ) { >+ my %od_info; >+ @od_info{ @branchcodes } = @authnames; >+ while( my($branchcode,$authname) = each %od_info){ >+ my $cur_info = Koha::Library::OverDriveInfos->find($branchcode); >+ if( $cur_info ) { >+ $cur_info->authname($authname)->store; >+ } else { >+ Koha::Library::OverDriveInfo->new({ >+ branchcode => $branchcode, >+ authname => $authname, >+ })->store; >+ } >+ } >+} >+ >+my @branches = Koha::Libraries->search(); >+my @branch_od_info; >+foreach my $branch ( @branches ){ >+ my $od_info = Koha::Library::OverDriveInfos->find($branch->branchcode); >+ if( $od_info ){ >+ push @branch_od_info, { branchcode => $od_info->branchcode, authname => $od_info->authname }; >+ } else { >+ push @branch_od_info, { branchcode => $branch->branchcode, authname => "" }; >+ } >+} >+ >+$template->param( >+ branches => \@branch_od_info, >+); >+ >+output_html_with_http_headers $input, $cookie, $template->output; >diff --git a/koha-tmpl/intranet-tmpl/prog/en/modules/admin/overdrive.tt b/koha-tmpl/intranet-tmpl/prog/en/modules/admin/overdrive.tt >new file mode 100644 >index 0000000000..dde99d3f43 >--- /dev/null >+++ b/koha-tmpl/intranet-tmpl/prog/en/modules/admin/overdrive.tt >@@ -0,0 +1,65 @@ >+[% USE Asset %] >+[% USE Branches %] >+[% USE HtmlTags %] >+[% SET footerjs = 1 %] >+[% INCLUDE 'doc-head-open.inc' %] >+<title>Koha › Administration › Library OverDrive Info ›</title> >+[% INCLUDE 'doc-head-close.inc' %] >+[% Asset.css("css/datatables.css") %] >+</head> >+ >+<body id="admin_overdrive" class="admin"> >+[% INCLUDE 'header.inc' %] >+ >+<div id="breadcrumbs"><a href="/cgi-bin/koha/mainpage.pl">Home</a> › <a href="/cgi-bin/koha/admin/admin-home.pl">Administration</a> › <a href="/cgi-bin/koha/admin/overdrive.pl">Library OverDrive Info</a> › >+</div> >+ >+<div id="doc3" class="yui-t2"> >+ >+<div id="bd"> >+ <div id="yui-main"> >+ <div class="yui-b"> >+ >+<form action="/cgi-bin/koha/admin/overdrive.pl" name="overdrive_form" method="post" class="validated"> >+ <input type="hidden" name="op" value="update" /> >+ <fieldset class="rows"> >+ <legend> >+ OverDrive >+ </legend> >+ <table id="od_info"> >+ <thead> >+ <th>Branch</th> >+ <th>Authname</th> >+ </thead> >+ <tbody> >+ [% FOREACH b IN branches %] >+ <tr> >+ <td> >+ [% Branches.GetName( b.branchcode ) %] >+ <input type="hidden" name="branchcode" value="[% b.branchcode %]" /> >+ </td> >+ <td> >+ <input type="text" name="authname" value="[% b.authname %]" /> >+ </td> >+ </tr> >+ [% END %] >+ </tbody> >+ </table> >+ <input type="submit" value="Submit"> >+</form> >+ >+</div> >+</div> >+<div class="yui-b"> >+[% INCLUDE 'admin-menu.inc' %] >+</div> >+</div> >+ >+[% MACRO jsinclude BLOCK %] >+ [% Asset.js("js/admin-menu.js") %] >+ [% INCLUDE 'datatables.inc' %] >+ [% INCLUDE 'columns_settings.inc' %] >+ <script type="text/javascript"> >+ </script> >+[% END %] >+[% INCLUDE 'intranet-bottom.inc' %] >diff --git a/t/db_dependent/Koha/Library/OverDriveInfos.t b/t/db_dependent/Koha/Library/OverDriveInfos.t >new file mode 100644 >index 0000000000..02802a3b6a >--- /dev/null >+++ b/t/db_dependent/Koha/Library/OverDriveInfos.t >@@ -0,0 +1,55 @@ >+#!/usr/bin/perl >+ >+# Copyright 2018 Koha Development team >+# >+# This file is part of Koha >+# >+# Koha is free software; you can redistribute it and/or modify it >+# under the terms of the GNU General Public License as published by >+# the Free Software Foundation; either version 3 of the License, or >+# (at your option) any later version. >+# >+# Koha is distributed in the hope that it will be useful, but >+# WITHOUT ANY WARRANTY; without even the implied warranty of >+# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the >+# GNU General Public License for more details. >+# >+# You should have received a copy of the GNU General Public License >+# along with Koha; if not, see <http://www.gnu.org/licenses>. >+ >+use Modern::Perl; >+ >+use Test::More tests => 4; >+ >+use Koha::Library::OverDriveInfos; >+use Koha::Database; >+ >+use t::lib::TestBuilder; >+ >+my $schema = Koha::Database->new->schema; >+$schema->storage->txn_begin; >+ >+my $builder = t::lib::TestBuilder->new; >+my $library1 = $builder->build({ source => 'Branch'}); >+my $library2 = $builder->build({ source => 'Branch'}); >+my $nb_of_infos = Koha::Library::OverDriveInfos->search->count; >+my $new_od_info_1 = Koha::Library::OverDriveInfo->new({ >+ branchcode => $library1->{'branchcode'}, >+ authname => 'Gorilla' >+})->store; >+my $new_od_info_2 = Koha::Library::OverDriveInfo->new({ >+ branchcode => $library2->{'branchcode'}, >+ authname => 'Cheese' >+})->store; >+ >+ >+is( $new_od_info_1->authname, "Gorilla", 'Adding a new authname should have set the authname'); >+is( Koha::Library::OverDriveInfos->search->count, $nb_of_infos + 2, 'The 2 infos should have been added' ); >+ >+my $retrieved_od_info_1 = Koha::Library::OverDriveInfos->find( $new_od_info_1->branchcode ); >+is( $retrieved_od_info_1->authname, $new_od_info_1->authname, 'Find an info by branch should return the correct info' ); >+ >+$retrieved_od_info_1->delete; >+is( Koha::Library::OverDriveInfos->search->count, $nb_of_infos + 1, 'Delete should have deleted the info' ); >+ >+$schema->storage->txn_rollback; >-- >2.19.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 21082
:
77053
|
77054
|
77055
|
77056
|
79792
|
79793
|
79794
|
79795
|
79894
|
79954
|
79955
|
79956
|
79957
|
79985
| 79986 |
79987