Bugzilla – Attachment 162612 Details for
Bug 18138
Use MARC modification template when adding/updating bibliographic records
Home
|
New
|
Browse
|
Search
|
[?]
|
Reports
|
Help
|
New Account
|
Log In
[x]
|
Forgot Password
Login:
[x]
[patch]
Bug 18138: (QA follow-up) Perltidy and 'staff client'
Bug-18138-QA-follow-up-Perltidy-and-staff-client.patch (text/plain), 16.92 KB, created by
David Gustafsson
on 2024-02-29 18:13:51 UTC
(
hide
)
Description:
Bug 18138: (QA follow-up) Perltidy and 'staff client'
Filename:
MIME Type:
Creator:
David Gustafsson
Created:
2024-02-29 18:13:51 UTC
Size:
16.92 KB
patch
obsolete
>From 7e5c073698e24911735da4cbe7c780faac6c8183 Mon Sep 17 00:00:00 2001 >From: David Gustafsson <david.gustafsson@ub.gu.se> >Date: Thu, 29 Feb 2024 17:20:03 +0100 >Subject: [PATCH] Bug 18138: (QA follow-up) Perltidy and 'staff client' > >* Perltidies files >* Fix atomic update (description and success message) >* Fix atomic update file permissions >* Update 'staff client' to 'staff interface' > >Signed-off-by: Katrin Fischer <katrin.fischer.83@web.de> >--- > admin/preferences.pl | 3 +- > cataloguing/addbiblio.pl | 5 +- > ...blio-marc-modification-template-syspref.pl | 18 ++-- > installer/data/mysql/mandatory/sysprefs.sql | 2 +- > .../admin/preferences/cataloguing.pref | 4 +- > svc/bib | 5 +- > .../Koha/MarcModificationTemplates.t | 22 ++-- > ...BiblioMarcModificationTemplatePreference.t | 100 ++++++++++-------- > 8 files changed, 90 insertions(+), 69 deletions(-) > mode change 100644 => 100755 installer/data/mysql/atomicupdate/bug_18138-edit-biblio-marc-modification-template-syspref.pl > >diff --git a/admin/preferences.pl b/admin/preferences.pl >index 3d6b64eb3d1..1d0f995ca67 100755 >--- a/admin/preferences.pl >+++ b/admin/preferences.pl >@@ -115,7 +115,8 @@ sub _get_chunk { > $add_blank = 1; > } > } elsif ( $options{choices} eq 'marcModTemplates' ) { >- $options{choices} = { map { $_->template_id => $_->name } Koha::MarcModificationTemplates->search->as_list }; >+ $options{choices} = >+ { map { $_->template_id => $_->name } Koha::MarcModificationTemplates->search->as_list }; > $add_blank = 1; > } else { > die 'Unrecognized source of preference values: ' . $options{'choices'}; >diff --git a/cataloguing/addbiblio.pl b/cataloguing/addbiblio.pl >index 586a27d45fb..01854a79acc 100755 >--- a/cataloguing/addbiblio.pl >+++ b/cataloguing/addbiblio.pl >@@ -682,9 +682,8 @@ if ( $op eq "addbiblio" ) { > if ($template_id) { > my $template = Koha::MarcModificationTemplates->find($template_id); > if ($template) { >- ModifyRecordWithTemplate($template_id, $record); >- } >- else { >+ ModifyRecordWithTemplate( $template_id, $record ); >+ } else { > croak "No MARC modification template exists with id \"$template_id\""; > } > } >diff --git a/installer/data/mysql/atomicupdate/bug_18138-edit-biblio-marc-modification-template-syspref.pl b/installer/data/mysql/atomicupdate/bug_18138-edit-biblio-marc-modification-template-syspref.pl >old mode 100644 >new mode 100755 >index 6fd8b901d78..f9a810f2670 >--- a/installer/data/mysql/atomicupdate/bug_18138-edit-biblio-marc-modification-template-syspref.pl >+++ b/installer/data/mysql/atomicupdate/bug_18138-edit-biblio-marc-modification-template-syspref.pl >@@ -1,14 +1,18 @@ > use Modern::Perl; > > return { >- bug_number => "18138", >- description => "Add system preference", >- up => sub { >+ bug_number => "18138", >+ description => "Use MARC modification template when adding/updating bibliographic records", >+ up => sub { > my ($args) = @_; >- my ($dbh, $out) = @$args{qw(dbh out)}; >+ my ( $dbh, $out ) = @$args{qw(dbh out)}; >+ > # Do you stuffs here >- $dbh->do(q{INSERT IGNORE INTO systempreferences ( `variable`, `value`, `options`, `explanation`, `type`) VALUES ('SaveBiblioMarcModificationTemplate', '', NULL, 'MARC modification template applied when saving bibliographic record in staff client or HTTP API', 'marcModTemplates')}); >+ $dbh->do( >+ q{INSERT IGNORE INTO systempreferences ( `variable`, `value`, `options`, `explanation`, `type`) VALUES ('SaveBiblioMarcModificationTemplate', '', NULL, 'MARC modification template applied when saving bibliographic record in staff interface or HTTP API', 'marcModTemplates')} >+ ); >+ > # Print useful stuff here >- say $out "System preference added"; >+ say $out "Added new system preference 'SaveBiblioMarcModificationTemplate'"; > }, >-} >+ } >diff --git a/installer/data/mysql/mandatory/sysprefs.sql b/installer/data/mysql/mandatory/sysprefs.sql >index a0304b65ece..7d21b1e9d79 100644 >--- a/installer/data/mysql/mandatory/sysprefs.sql >+++ b/installer/data/mysql/mandatory/sysprefs.sql >@@ -668,8 +668,8 @@ INSERT INTO systempreferences ( `variable`, `value`, `options`, `explanation`, ` > ('RoutingListAddReserves','0','','If ON the patrons on routing lists are automatically added to holds on the issue.','YesNo'), > ('RoutingListNote','To change this note edit <a href=\"/cgi-bin/koha/admin/preferences.pl?op=search&searchfield=RoutingListNote#jumped\">RoutingListNote</a> system preference.','70|10','Define a note to be shown on all routing lists','Textarea'), > ('RoutingSerials','1',NULL,'If ON, serials routing is enabled','YesNo'), >-('SavedSearchFilters', '0', NULL, 'Allow staff with permission to create/edit custom search filters', 'YesNo'), > ('SaveBiblioMarcModificationTemplate', '', NULL, 'MARC modification template applied when saving bibliographic record in staff client or HTTP API', 'marcModTemplates'), >+('SavedSearchFilters', '0', NULL, 'Allow staff with permission to create/edit custom search filters', 'YesNo'), > ('SCOAllowCheckin','0','','If enabled, patrons may return items through the Web-based Self Checkout','YesNo'), > ('SCOLoadCheckoutsByDefault','1','','If enabled, load the list of a patrons checkouts when they log in to the Self Checkout','YesNo'), > ('SCOUserCSS','',NULL,'Add CSS to be included in the SCO module in an embedded <style> tag.','free'), >diff --git a/koha-tmpl/intranet-tmpl/prog/en/modules/admin/preferences/cataloguing.pref b/koha-tmpl/intranet-tmpl/prog/en/modules/admin/preferences/cataloguing.pref >index 23c9e9e9236..30a17f46b0b 100644 >--- a/koha-tmpl/intranet-tmpl/prog/en/modules/admin/preferences/cataloguing.pref >+++ b/koha-tmpl/intranet-tmpl/prog/en/modules/admin/preferences/cataloguing.pref >@@ -218,10 +218,10 @@ Cataloging: > 0: "Don't strip" > - leading and trailing whitespace characters (including spaces, tabs, line breaks and carriage returns) and inner newlines from data fields when cataloguing bibliographic and authority records. The leader and control fields will not be affected. > - >- - Apply the MARC modification template with name >+ - Apply the MARC modification template > - pref: SaveBiblioMarcModificationTemplate > choices: marcModTemplates >- - on records saved using the staff client simple MARC editor, advanced editor or HTTP API. >+ - on records saved using the staff interface simple MARC editor, advanced editor or HTTP API. > Display: > - > - 'Separate main entry and subdivisions with ' >diff --git a/svc/bib b/svc/bib >index 25df608f3dd..7d055af3ce2 100755 >--- a/svc/bib >+++ b/svc/bib >@@ -132,9 +132,8 @@ sub update_bib { > if ($template_id) { > my $template = Koha::MarcModificationTemplates->find($template_id); > if ($template) { >- ModifyRecordWithTemplate($template_id, $record); >- } >- else { >+ ModifyRecordWithTemplate( $template_id, $record ); >+ } else { > croak "No MARC modification template exists with id \"$template_id\""; > } > } >diff --git a/t/db_dependent/Koha/MarcModificationTemplates.t b/t/db_dependent/Koha/MarcModificationTemplates.t >index 8b1a17644ac..184a31471bb 100755 >--- a/t/db_dependent/Koha/MarcModificationTemplates.t >+++ b/t/db_dependent/Koha/MarcModificationTemplates.t >@@ -30,16 +30,20 @@ use t::lib::TestBuilder; > my $schema = Koha::Database->new->schema; > $schema->storage->txn_begin; > >-my $builder = t::lib::TestBuilder->new; >+my $builder = t::lib::TestBuilder->new; > my $nb_of_mmts = Koha::MarcModificationTemplates->search->count; >-my $new_mmt_1 = Koha::MarcModificationTemplate->new({ >- name => 'my_mmt_name_for_test_1', >-})->store; >-my $new_mmt_2 = Koha::MarcModificationTemplate->new({ >- name => 'my_mmt_name_for_test_2', >-})->store; >- >-like( $new_mmt_1->template_id, qr|^\d+$|, 'Adding a new mmt should have set the id'); >+my $new_mmt_1 = Koha::MarcModificationTemplate->new( >+ { >+ name => 'my_mmt_name_for_test_1', >+ } >+)->store; >+my $new_mmt_2 = Koha::MarcModificationTemplate->new( >+ { >+ name => 'my_mmt_name_for_test_2', >+ } >+)->store; >+ >+like( $new_mmt_1->template_id, qr|^\d+$|, 'Adding a new mmt should have set the id' ); > is( Koha::MarcModificationTemplates->search->count, $nb_of_mmts + 2, 'The 2 templates should have been added' ); > > my $retrieved_mmt_1 = Koha::MarcModificationTemplates->find( $new_mmt_1->template_id ); >diff --git a/t/db_dependent/www/EditBiblioMarcModificationTemplatePreference.t b/t/db_dependent/www/EditBiblioMarcModificationTemplatePreference.t >index 0841872419c..e59ebe6a817 100755 >--- a/t/db_dependent/www/EditBiblioMarcModificationTemplatePreference.t >+++ b/t/db_dependent/www/EditBiblioMarcModificationTemplatePreference.t >@@ -27,21 +27,19 @@ use Koha::MarcModificationTemplates; > use C4::Biblio qw(AddBiblio ModBiblioMarc DelBiblio); > use Koha::Biblios; > >-eval{ >- use C4::Context; >-}; >+eval { use C4::Context; }; > if ($@) { > plan skip_all => "Tests skip. You must have a working Context\n"; > } > >-my $koha_conf = $ENV{KOHA_CONF}; >+my $koha_conf = $ENV{KOHA_CONF}; > my $koha_conf_xml = XMLin($koha_conf); > > my $user = $ENV{KOHA_USER} || $koha_conf_xml->{config}->{user}; > my $password = $ENV{KOHA_PASS} || $koha_conf_xml->{config}->{pass}; > my $intranet = $ENV{KOHA_INTRANET_URL}; > >-if (not defined $intranet) { >+if ( not defined $intranet ) { > plan skip_all => "Tests skipped. You must set environment variable KOHA_INTRANET_URL to run tests\n"; > } > >@@ -50,16 +48,16 @@ subtest 'Templates applied using simple and advanced MARC Editor' => sub { > > # Create "Test" MARC modification template > #my $template_id = AddModificationTemplate('TEST'); >- my $template = Koha::MarcModificationTemplate->new({ name => 'TEST' })->store; >+ my $template = Koha::MarcModificationTemplate->new( { name => 'TEST' } )->store; > >- ok($template, 'MARC modification template successfully created'); >+ ok( $template, 'MARC modification template successfully created' ); > my $add_template_action_result = AddModificationTemplateAction( > $template->id, >- 'update_field', # Action >+ 'update_field', # Action > 0, >- 250, # Field >- 'a', # Subfield >- '251 bottles of beer on the wall', # Value >+ 250, # Field >+ 'a', # Subfield >+ '251 bottles of beer on the wall', # Value > '', > '', > '', >@@ -73,56 +71,66 @@ subtest 'Templates applied using simple and advanced MARC Editor' => sub { > 0, > '' > ); >- ok($add_template_action_result, 'MARC modification template action successfully created'); >- my $record = MARC::Record->new(); >+ ok( $add_template_action_result, 'MARC modification template action successfully created' ); >+ my $record = MARC::Record->new(); > $record->leader(' nam a22 7a 4500'); > $record->append_fields( >- MARC::Field->new('001', '12345'), >- MARC::Field->new('003', 'TEST'), >- MARC::Field->new('245', '1', '0', 'a' => 'TEST'), >- MARC::Field->new('250', '','', 'a' => '250 bottles of beer on the wall'), >+ MARC::Field->new( '001', '12345' ), >+ MARC::Field->new( '003', 'TEST' ), >+ MARC::Field->new( '245', '1', '0', 'a' => 'TEST' ), >+ MARC::Field->new( '250', '', '', 'a' => '250 bottles of beer on the wall' ), >+ > # @FIXME: Create test item type? Not super safe to rely on existing 'BK' type >- MARC::Field->new('942', '','', 'c' => 'BK'), >+ MARC::Field->new( '942', '', '', 'c' => 'BK' ), > ); >- my ($biblionumber) = AddBiblio($record, ''); >+ my ($biblionumber) = AddBiblio( $record, '' ); > >- my $saved_record = Koha::Biblios->find($biblionumber)->metadata->record(); >+ my $saved_record = Koha::Biblios->find($biblionumber)->metadata->record(); > my $saved_record_250_field = $saved_record->field('250'); >- isa_ok($saved_record_250_field, 'MARC::Field', 'Field with tag 250 has been saved'); >- is($saved_record_250_field->subfield('a'), '250 bottles of beer on the wall', 'Field 250a has the same value passed to AddBiblio'); >+ isa_ok( $saved_record_250_field, 'MARC::Field', 'Field with tag 250 has been saved' ); >+ is( >+ $saved_record_250_field->subfield('a'), '250 bottles of beer on the wall', >+ 'Field 250a has the same value passed to AddBiblio' >+ ); > > my $old_template_preference = C4::Context->preference('SaveBiblioMarcModificationTemplate'); >- C4::Context->set_preference('SaveBiblioMarcModificationTemplate', $template->id); >+ C4::Context->set_preference( 'SaveBiblioMarcModificationTemplate', $template->id ); > >- my $agent = Test::WWW::Mechanize->new(autocheck => 1); >+ my $agent = Test::WWW::Mechanize->new( autocheck => 1 ); > >- $agent->get_ok("$intranet/cgi-bin/koha/mainpage.pl", 'Connect to intranet'); >+ $agent->get_ok( "$intranet/cgi-bin/koha/mainpage.pl", 'Connect to intranet' ); > $agent->form_name('loginform'); >- $agent->field('password', $password); >- $agent->field('userid', $user); >- $agent->field('branch', ''); >- $agent->click_ok('', 'Login to staff interface'); >- $agent->content_lacks('Invalid username or password', 'Logged in to staff interface'); >- >- $agent->get_ok("$intranet/cgi-bin/koha/cataloguing/addbiblio.pl?biblionumber=$biblionumber", 'Load bibliographic record in simple MARC editor'); >+ $agent->field( 'password', $password ); >+ $agent->field( 'userid', $user ); >+ $agent->field( 'branch', '' ); >+ $agent->click_ok( '', 'Login to staff interface' ); >+ $agent->content_lacks( 'Invalid username or password', 'Logged in to staff interface' ); >+ >+ $agent->get_ok( >+ "$intranet/cgi-bin/koha/cataloguing/addbiblio.pl?biblionumber=$biblionumber", >+ 'Load bibliographic record in simple MARC editor' >+ ); > $agent->submit_form_ok( > { > form_id => 'f', >- button => '', >+ button => '', > }, > 'Save bibliographic record using simple MARC editor' > ); > >- $saved_record = Koha::Biblios->find($biblionumber)->metadata->record(); >+ $saved_record = Koha::Biblios->find($biblionumber)->metadata->record(); > $saved_record_250_field = $saved_record->field('250'); >- is($saved_record_250_field->subfield('a'), '251 bottles of beer on the wall', 'Field with tag 250 has been modified by MARC modification template'); >+ is( >+ $saved_record_250_field->subfield('a'), '251 bottles of beer on the wall', >+ 'Field with tag 250 has been modified by MARC modification template' >+ ); > > # FIXME: Don't really need to to this, but could be useful so >- # test below does not succed by accident >+ # test below does not succeed by accident > $saved_record->delete_fields($saved_record_250_field); >- $saved_record->insert_fields_ordered(MARC::Field->new('250', '','', 'a' => '250 bottles of beer on the wall')); >- $biblionumber = ModBiblioMarc($saved_record, $biblionumber); >- ok($biblionumber, 'Field with tag 250 has been restored to original value'); >+ $saved_record->insert_fields_ordered( MARC::Field->new( '250', '', '', 'a' => '250 bottles of beer on the wall' ) ); >+ $biblionumber = ModBiblioMarc( $saved_record, $biblionumber ); >+ ok( $biblionumber, 'Field with tag 250 has been restored to original value' ); > > # @FIXME: Leader record status n or c? > my $record_xml = <<'EOF'; >@@ -145,14 +153,20 @@ EOF > my $headers = HTTP::Headers->new( > Content_Type => 'text/xml', > ); >- my $request = HTTP::Request->new('POST', "$intranet/cgi-bin/koha/svc/bib/$biblionumber", $headers, $record_xml); >+ my $request = HTTP::Request->new( 'POST', "$intranet/cgi-bin/koha/svc/bib/$biblionumber", $headers, $record_xml ); > my $response = $agent->request($request); > >- is($response->code, '200', 'Emulate save in advanced MARC editor, Koha REST API responded with 200 for update biblio request'); >- like($response->decoded_content, qr/251 bottles of beer on the wall/, 'Field with tag 250 has been modified by MARC modification template'); >+ is( >+ $response->code, '200', >+ 'Emulate save in advanced MARC editor, Koha REST API responded with 200 for update biblio request' >+ ); >+ like( >+ $response->decoded_content, qr/251 bottles of beer on the wall/, >+ 'Field with tag 250 has been modified by MARC modification template' >+ ); > > # Clean up > DelBiblio($biblionumber); > $template->delete; >- C4::Context->set_preference('SaveBiblioMarcModificationTemplate', $old_template_preference); >+ C4::Context->set_preference( 'SaveBiblioMarcModificationTemplate', $old_template_preference ); > }; >-- >2.43.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 18138
:
61442
|
61443
|
61734
|
82783
|
86617
|
110266
|
110269
|
110270
|
110272
|
118439
|
118440
|
118441
|
118442
|
118443
|
118444
|
118824
|
120709
|
123125
|
123127
|
123128
|
123129
|
123130
|
123131
|
123132
|
123133
|
123137
|
124466
|
124467
|
124468
|
124469
|
124470
|
124471
|
124472
|
124473
|
124474
|
124475
|
124476
|
124477
|
124478
|
124484
|
124485
|
124486
|
124492
|
124493
|
124991
|
125157
|
148004
|
148005
|
148006
|
148007
|
148008
|
148009
|
157183
|
157184
|
157185
|
157186
|
157187
|
157188
|
157189
|
157190
|
157485
|
157486
|
157487
|
157488
|
157489
|
157490
|
157491
|
158414
|
158415
|
158416
|
158417
|
158418
|
158419
|
158420
|
158421
| 162612 |
162613