Bugzilla – Attachment 88496 Details for
Bug 18823
Advanced editor - Rancor - add ability to edit records in import batches
Home
|
New
|
Browse
|
Search
|
[?]
|
Reports
|
Help
|
New Account
|
Log In
[x]
|
Forgot Password
Login:
[x]
[patch]
Bug 18823: Rancor - improve batch search/update ISBN handling
Bug-18823-Rancor---improve-batch-searchupdate-ISBN.patch (text/plain), 8.11 KB, created by
Alex Arnaud
on 2019-04-23 14:39:12 UTC
(
hide
)
Description:
Bug 18823: Rancor - improve batch search/update ISBN handling
Filename:
MIME Type:
Creator:
Alex Arnaud
Created:
2019-04-23 14:39:12 UTC
Size:
8.11 KB
patch
obsolete
>From d126a9f6755d053c87b9083a879abd04ebadd29d Mon Sep 17 00:00:00 2001 >From: Cori Lynn Arnold <carnold@dgiinc.com> >Date: Mon, 15 Oct 2018 19:16:20 +0000 >Subject: [PATCH] Bug 18823: Rancor - improve batch search/update ISBN handling > >Rebase > >Signed-off-by: cori <corilynn.arnold@gmail.com> >Rebased-on: 2019-03-20 Alex Arnaud <alex.arnaud@biblibre.com> >--- > C4/ImportBatch.pm | 29 +++++++++++++++++++--- > Koha/MetaSearcher.pm | 14 +++++++++-- > .../prog/en/includes/cateditor-ui.inc | 8 +++--- > .../prog/en/modules/cataloguing/editor.tt | 7 +++--- > svc/cataloguing/import_batches | 3 ++- > 5 files changed, 47 insertions(+), 14 deletions(-) > >diff --git a/C4/ImportBatch.pm b/C4/ImportBatch.pm >index 03c4fda..7efec55 100644 >--- a/C4/ImportBatch.pm >+++ b/C4/ImportBatch.pm >@@ -1606,6 +1606,29 @@ sub _create_import_record { > return $import_record_id; > } > >+sub _get_import_record_timestamp { >+ my ( $marc_record ) = @_; >+ my $upload_timestamp = DateTime->now(); >+ >+ # Attempt to parse the 005 timestamp. This is a bit weird because we have to parse the >+ # tenth-of-a-second ourselves. >+ my $f005 = $marc_record->field('005'); >+ if ($f005 && $f005->data =~ /(\d{8}\d{6})\.(\d)/ ) { >+ my $parser = DateTime::Format::Strptime->new( pattern => '%Y%m%d%H%M%S' ); >+ my $parsed_timestamp = $parser->parse_datetime($1); >+ >+ # We still check for success because we only did enough validation above to extract the >+ # tenth-of-a-second; the timestamp could still be some nonsense like the 50th of Jantober. >+ if ( $parsed_timestamp ) { >+ $parsed_timestamp->set_nanosecond( $2 * 100_000_000 ); >+ $upload_timestamp = $parsed_timestamp; >+ } >+ } >+ >+ return $upload_timestamp; >+} >+ >+ > sub _update_import_record_marc { > my ($import_record_id, $marc_record, $marc_type) = @_; > >@@ -1654,11 +1677,9 @@ sub _update_biblio_fields { > > my ($title, $author, $isbn, $issn) = _parse_biblio_fields($marc_record); > my $dbh = C4::Context->dbh; >- # FIXME no controlnumber, originalsource >+ # FIXME no originalsource > # FIXME 2 - should regularize normalization of ISBN wherever it is done >- $isbn =~ s/\(.*$//; >- $isbn =~ tr/ -_//; >- $isbn = uc $isbn; >+ $isbn = C4::Koha::GetNormalizedISBN($isbn); > my $sth = $dbh->prepare("UPDATE import_biblios SET title = ?, author = ?, isbn = ?, issn = ? > WHERE import_record_id = ?"); > $sth->execute($title, $author, $isbn, $issn, $import_record_id); >diff --git a/Koha/MetaSearcher.pm b/Koha/MetaSearcher.pm >index 366e98b..161f1d5 100644 >--- a/Koha/MetaSearcher.pm >+++ b/Koha/MetaSearcher.pm >@@ -22,6 +22,7 @@ use Modern::Perl; > use base 'Class::Accessor'; > > use C4::Charset qw( MarcToUTF8Record ); >+use C4::Koha qw(); # Purely for GetNormalizedISBN > use C4::Search qw(); # Purely for new_record_from_zebra > use DBIx::Class::ResultClass::HashRefInflator; > use IO::Select; >@@ -238,8 +239,17 @@ sub _db_query_get_match_conditions { > if ( $value =~ /\*/ ) { > $value =~ s/\*/%/; > return { -like => $value }; >+ } elsif ( $index eq 'isbn' ) { >+ return C4::Koha::GetNormalizedISBN($value) || $value; > } elsif ( $_batch_db_text_columns->{$index} ) { >- return map +{ -regexp => '[[:<:]]' . $_ . '[[:>:]]' }, split( /\s+/, $value ); >+ my $stripped_value = $value; >+ >+ $stripped_value =~ s/[^\w]//g; >+ $stripped_value =~ s/^ +| +$//g; >+ >+ return $value if ( !$stripped_value ); >+ >+ return map +{ -regexp => '[[:<:]]' . $_ . '[[:>:]]' }, split( /\s+/, $stripped_value ); > } else { > return $value; > } >@@ -264,7 +274,7 @@ sub _batch_db_query_from_terms { > push @db_terms, $_batch_db_mapping->{$index} => [ -and => _db_query_get_match_conditions( $index, $value ) ]; > } else { > # No such index, we should fail >- return undef; >+ die("No such index"); > } > } > >diff --git a/koha-tmpl/intranet-tmpl/prog/en/includes/cateditor-ui.inc b/koha-tmpl/intranet-tmpl/prog/en/includes/cateditor-ui.inc >index dba8f3e..476cdfb 100644 >--- a/koha-tmpl/intranet-tmpl/prog/en/includes/cateditor-ui.inc >+++ b/koha-tmpl/intranet-tmpl/prog/en/includes/cateditor-ui.inc >@@ -42,7 +42,7 @@ require( [ 'koha-backend', 'search', 'macros', 'marc-editor', 'marc-record', 'pr > }, > [%- FOREACH batch = editable_batches -%] > 'batch:[% batch.import_batch_id %]': { >- name: _("Batch: ") + '[% batch.file_name %]', >+ name: _("Batch: ") + `[% batch.file_name %]`, > recordtype: 'biblio', > checked: false, > }, >@@ -314,7 +314,7 @@ require( [ 'koha-backend', 'search', 'macros', 'marc-editor', 'marc-record', 'pr > var editable_batches = { > [%- FOREACH batch = editable_batches -%] > [% batch.import_batch_id %]: { >- 'name': '[% batch.file_name %]', >+ 'name': `[% batch.file_name %]`, > }, > [%- END -%] > }; >@@ -339,7 +339,7 @@ require( [ 'koha-backend', 'search', 'macros', 'marc-editor', 'marc-record', 'pr > > $.each( target_list, function( i, target ) { > var $new_target = $( >- '<li><input type="checkbox" class="save-toggle-target" data-target-id="' + target.id + '" id="save-target-' + i + '"' + ( target.checked ? ' checked="checked"' : '' ) + '> <label for="save-target-' + i + '">' + target.label + '</label></li>' >+ '<li><input type="checkbox" class="save-toggle-target" data-target-id="' + target.id + '" id="save-target-' + i + '"' + ( target.checked ? ' checked="checked"' : '' ) + `> <label for="save-target-` + i + `">` + target.label + `</label></li>` > ); > > $new_target.find('input').change( function() { >@@ -1408,7 +1408,7 @@ require( [ 'koha-backend', 'search', 'macros', 'marc-editor', 'marc-record', 'pr > $('#loading').hide(); > } > ); >- }; ); >+ } ); > > $.each( backends, function( name ) { > if ( !this.save ) return; // Not a saving backend >diff --git a/koha-tmpl/intranet-tmpl/prog/en/modules/cataloguing/editor.tt b/koha-tmpl/intranet-tmpl/prog/en/modules/cataloguing/editor.tt >index 74dcd58..1faf0e9 100644 >--- a/koha-tmpl/intranet-tmpl/prog/en/modules/cataloguing/editor.tt >+++ b/koha-tmpl/intranet-tmpl/prog/en/modules/cataloguing/editor.tt >@@ -276,6 +276,7 @@ > > <div id="batches-ui" class="ui-modal modal fade" tabindex="-1" role="dialog" aria-labelledby="batches-title" aria-hidden="true"> > >+<div class="modal-content"> > <div class="modal-header"> > <button type="button" class="closebtn" data-dismiss="modal" aria-hidden="true">Ã</button> > <h3 id="batches-title">Import batch settings</h3> >@@ -284,8 +285,8 @@ > <div class="modal-body row-fluid"> > <div class="span9"> > <div id="toolbar" class="btn-toolbar"> >- <button class="btn btn-small" type="submit" id="create-batch"><i class="icon-plus"></i> <span>Create new batch...</span></button> >- <button class="btn btn-small" type="submit" id="manage-batches"><i class="icon-list"></i> <span>Manage import batches...</span></button> >+ <button class="btn btn-sm" type="submit" id="create-batch"><i class="icon-plus"></i> <span>Create new batch...</span></button> >+ <button class="btn btn-sm" type="submit" id="manage-batches"><i class="icon-list"></i> <span>Manage import batches...</span></button> > </div> > <table id="batches-table"> > <thead> >@@ -303,7 +304,7 @@ > <div class="span3"> > </div> > </div> >- >+<div> > </div> > > <div id="shortcuts-contents" style="display: none"> >diff --git a/svc/cataloguing/import_batches b/svc/cataloguing/import_batches >index 883f3a5..6bf5fdb 100755 >--- a/svc/cataloguing/import_batches >+++ b/svc/cataloguing/import_batches >@@ -195,7 +195,8 @@ sub create_batch { > > my $batch_id = AddImportBatch({ > file_name => $batch_name, >- record_type => 'biblio' >+ record_type => 'biblio', >+ import_status => 'staged' > }); > > $response->param( batch_id => $batch_id ); >-- >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 18823
:
64434
|
66882
|
66883
|
66884
|
66885
|
66919
|
77240
|
77241
|
77242
|
77243
|
77244
|
79240
|
79241
|
79242
|
79243
|
79244
|
80519
|
80536
|
80604
|
80606
|
80608
|
80613
|
80626
|
80627
|
80628
|
80637
|
80639
|
80651
|
80861
|
80866
|
80868
|
80869
|
80870
|
80871
|
80872
|
80873
|
80947
|
85355
|
85356
|
85357
|
85358
|
85359
|
85376
|
85719
|
85720
|
85785
|
85828
|
86087
|
86173
|
86174
|
86175
|
86176
|
86177
|
86178
|
86179
|
86180
|
86181
|
86182
|
86183
|
86791
|
86792
|
86793
|
86794
|
86795
|
86796
|
86797
|
86798
|
86799
|
88417
|
88418
|
88419
|
88420
|
88421
|
88422
|
88423
|
88424
|
88425
|
88426
|
88427
|
88428
|
88429
|
88430
|
88431
|
88432
|
88493
|
88494
|
88495
|
88496
|
88497
|
88498
|
88499
|
88500
|
88501
|
88502
|
88503
|
88504
|
88505
|
88506
|
88507
|
88508
|
91205
|
91206
|
91207
|
91208
|
91209
|
91210
|
91211
|
91212
|
91213
|
91214
|
91215
|
91216
|
91217
|
91218
|
91219
|
92051
|
92120
|
92124
|
94436
|
94437
|
94438
|
94439
|
94440
|
94441
|
94442
|
94443
|
94444
|
94445
|
94446
|
94447
|
94448
|
94449
|
94450
|
94451
|
94452
|
99092
|
99093
|
99094
|
99095
|
99096
|
99097
|
99098
|
99099
|
99100
|
99101
|
99102
|
99103
|
99104
|
99105
|
99106
|
99107
|
99108
|
99109