From 5a948abe7a97e577073c330321e919de9e528e57 Mon Sep 17 00:00:00 2001 From: mxbeaulieu Date: Tue, 7 Jul 2015 16:26:53 -0400 Subject: [PATCH] Bug 11299 - Follow-up to QA failure Fixes problems reported by koha-qa use Modern::Perl Changed required permission to editauthorities pertidy cataloguing/automatic_linker.pl Testing scenario (Creating an authority record for a failed automatic link) : * In you system preferences, deactivate the "AutoCreateAuthorities" preference. * Go to the biblio record creation form to create a new biblio record. (koha/cataloguing/addbiblio.pl) * Click the "Link authorities automatically" button. A message should appear, telling the user "No authority link was changed." * Add random informations in field 600$a of the biblio record. * Click the "Link authorities automatically" button. The message box should now show "600 - No matching authority found." if no matching authority was found. For this scenario, we want the authority match to have failed. * The 600$9 field should now be red and icons should have appeared next to it. Click on the "create authority" icon. * A popup should appear, containing a "Modify authority" form. The form should be pre-filled, a the informations in the 600$a field of the biblio should be in the 100$a field of this new authority record. * Click the "Save" button * The 600$9 field in the biblio record should now be back to normal and have the authid of the authority record that was just created. * Click the "Link authorities automatically" button again. The message box should now show "No authority link was changed.". I tried it and got the expected results. (In reply to Jonathan Druart from comment #18) > 5/ * Click the "Link authorities automatically" button. A message should appear, telling the user "No authority link was changed." > > No, I got > Automatic authority link results: > 700 - No matching authority found. > ... Jonathan, did you create the biblio from scratch? The record you tested probably had data in the 700 field. Tests will be included in a future patch. --- cataloguing/automatic_linker.pl | 29 +++++--- .../prog/en/modules/cataloguing/addbiblio.tt | 78 ++++++++++---------- 2 files changed, 56 insertions(+), 51 deletions(-) diff --git a/cataloguing/automatic_linker.pl b/cataloguing/automatic_linker.pl index a853398..a17e7ea 100755 --- a/cataloguing/automatic_linker.pl +++ b/cataloguing/automatic_linker.pl @@ -6,7 +6,7 @@ # # 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 2 of the License, or (at your option) any later +# 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 @@ -17,8 +17,7 @@ # with Koha; if not, write to the Free Software Foundation, Inc., # 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA. -use strict; -use warnings; +use Modern::Perl; use CGI; use CGI::Cookie; use JSON; @@ -26,15 +25,16 @@ use C4::Auth; use C4::Biblio; use C4::Context; -my $input = new CGI; +my $input = new CGI; print $input->header('application/json'); # Check the user's permissions my %cookies = fetch CGI::Cookie; my $sessid = $cookies{'CGISESSID'}->value || $input->param('CGISESSID'); -my ($auth_status, $auth_sessid) = C4::Auth::check_cookie_auth($sessid, {catalogue => 1}); -if ($auth_status ne "ok") { - print to_json({status => 'UNAUTHORIZED'}); +my ( $auth_status, $auth_sessid ) = + C4::Auth::check_cookie_auth( $sessid, { editauthorities => 1 } ); +if ( $auth_status ne "ok" ) { + print to_json( { status => 'UNAUTHORIZED' } ); exit 0; } @@ -47,10 +47,10 @@ if ($auth_status ne "ok") { my $json; -my $record = TransformHtmlToMarc( $input ); +my $record = TransformHtmlToMarc($input); - -my $linker_module = "C4::Linker::" . ( C4::Context->preference("LinkerModule") || 'Default' ); +my $linker_module = + "C4::Linker::" . ( C4::Context->preference("LinkerModule") || 'Default' ); eval { eval "require $linker_module"; }; if ($@) { $linker_module = 'C4::Linker::Default'; @@ -59,9 +59,14 @@ if ($@) { if ($@) { return 0, 0; } -my $linker = $linker_module->new( { 'options' => C4::Context->preference("LinkerOptions") } ); +my $linker = $linker_module->new( + { 'options' => C4::Context->preference("LinkerOptions") } ); -my ( $headings_changed, $results ) = LinkBibHeadingsToAuthorities( $linker, $record, $input->param('frameworkcode'), C4::Context->preference("CatalogModuleRelink") || '', 1 ); +my ( $headings_changed, $results ) = LinkBibHeadingsToAuthorities( + $linker, $record, + $input->param('frameworkcode'), + C4::Context->preference("CatalogModuleRelink") || '', 1 +); $json->{status} = 'OK'; $json->{links} = $results->{details} || ''; diff --git a/koha-tmpl/intranet-tmpl/prog/en/modules/cataloguing/addbiblio.tt b/koha-tmpl/intranet-tmpl/prog/en/modules/cataloguing/addbiblio.tt index 659532f..ae6936d 100644 --- a/koha-tmpl/intranet-tmpl/prog/en/modules/cataloguing/addbiblio.tt +++ b/koha-tmpl/intranet-tmpl/prog/en/modules/cataloguing/addbiblio.tt @@ -144,46 +144,46 @@ function PopupZ3950() { } function addCreateAuthorityButton(tag_subfield_line, tag, index) { - var title = _("Create authority"); - var elem = $(''); - tag_subfield_line.append(elem); + var title = _("Create authority"); + var elem = $(''); + tag_subfield_line.append(elem); - elem.click(function() { + elem.click(function() { var biblioindex = $(this).parents('.subfield_line').find('input').eq(1).attr('id'); - var popup = window.open("", "new_auth_popup",'width=700,height=550,toolbar=false,scrollbars=yes'); - - if(popup !== null) { - // Create a new form that will be POSTed in the new window - var form = $('
').attr({ - method: 'post', - action: "../authorities/authorities.pl", - target: "new_auth_popup" - }); - - // Add the biblioindex - form.append($('').attr({ - type: 'hidden', - name: 'biblioindex', - value: biblioindex - })); - - // Get all form datas for the current heading field - $('.tag[id^=tag_' + tag + '_]').eq(index).find(':input').each(function(){ - form.append($('').attr({ - type: 'hidden', - name: this.name, - value: $(this).val() - })); - }); - - // We need to add the temporary form to the body so we can submit it - $('body').append(form); - form.submit(); - form.remove(); - } + var popup = window.open("", "new_auth_popup",'width=700,height=550,toolbar=false,scrollbars=yes'); + + if(popup !== null) { + // Create a new form that will be POSTed in the new window + var form = $('').attr({ + method: 'post', + action: "../authorities/authorities.pl", + target: "new_auth_popup" + }); + + // Add the biblioindex + form.append($('').attr({ + type: 'hidden', + name: 'biblioindex', + value: biblioindex + })); + + // Get all form datas for the current heading field + $('.tag[id^=tag_' + tag + '_]').eq(index).find(':input').each(function(){ + form.append($('').attr({ + type: 'hidden', + name: this.name, + value: $(this).val() + })); + }); - return false; - }); + // We need to add the temporary form to the body so we can submit it + $('body').append(form); + form.submit(); + form.remove(); + } + + return false; + }); } /** @@ -253,14 +253,14 @@ function updateHeadingLinks(links) { } subfield.css({backgroundColor:field_color}); - tag_subfield_line.append(''); + tag_subfield_line.append(''); // Add the message to the dialog message_dialog_ul.append('
  • ' + heading.tag + ' - ' + message + '
  • '); // Add a link to create a new authority if none was found if(heading.status == 'NONE_FOUND') { - addCreateAuthorityButton(tag_subfield_line, heading.tag, tag_index); + addCreateAuthorityButton(tag_subfield_line, heading.tag, tag_index); } }); -- 1.7.9.5