Bugzilla – Attachment 135264 Details for
Bug 30195
Suggestion form in OPAC should use ISBN to FindDuplicate
Home
|
New
|
Browse
|
Search
|
[?]
|
Reports
|
Help
|
New Account
|
Log In
[x]
|
Forgot Password
Login:
[x]
[patch]
Bug 30195: Search by ISBN if it is provided in suggestion
Bug-30195-Search-by-ISBN-if-it-is-provided-in-sugg.patch (text/plain), 5.62 KB, created by
Paul Derscheid
on 2022-05-23 13:30:03 UTC
(
hide
)
Description:
Bug 30195: Search by ISBN if it is provided in suggestion
Filename:
MIME Type:
Creator:
Paul Derscheid
Created:
2022-05-23 13:30:03 UTC
Size:
5.62 KB
patch
obsolete
>From 69c8263ef8f59c8e931c1453de5947e61e7bb815 Mon Sep 17 00:00:00 2001 >From: Thomas Klausner <domm@plix.at> >Date: Tue, 15 Mar 2022 16:00:48 +0100 >Subject: [PATCH] Bug 30195: Search by ISBN if it is provided in suggestion >MIME-Version: 1.0 >Content-Type: text/plain; charset=UTF-8 >Content-Transfer-Encoding: 8bit > >When a patron enters an ISBN/ISSN when suggesting a new purchase, the >ISBN is used to find duplicates. Title/Author are ignored (as patrons >might misspell them, and the ISBN provides a better way to find >duplicates) > >Test Plan: >* in the OPAC, go to /cgi-bin/koha/opac-suggestions.pl >* Click "new purchase suggestion" >* Enter any title >* Enter an ISBN that exists in your library >* Click "Submit your suggestion" >-> A new purchase suggestion has been submitted > >* Apply the patch! > >* Again start a new purchase suggestion, enter any title and the > duplicate ISBN, and Submit >* You should see the note "A similar document already exists: ..." > >Please note that the title should not be required when entering an ISBN, >but as the list of required fields is managed via OPACSuggestionMandatoryFields >I fear that it's rather complicated to make title an optional required >field if isbn is provided. > >I also added a simple non-DB test case to t/db_dependent/Suggestions.t >(in a subtest at the end), but could not actually run it as I haven't >gotten around to set up / try a testing Koha dev env... > >Sponsored-by: Steiermärkische Landesbibliothek >Signed-off-by: Paul Derscheid <paul.derscheid@lmscloud.de> >--- > C4/Suggestions.pm | 28 +++++++++++++++++++--------- > suggestion/suggestion.pl | 1 + > t/db_dependent/Suggestions.t | 22 ++++++++++++++++++++++ > 3 files changed, 42 insertions(+), 9 deletions(-) > >diff --git a/C4/Suggestions.pm b/C4/Suggestions.pm >index 649fb964e5..2758ec7030 100644 >--- a/C4/Suggestions.pm >+++ b/C4/Suggestions.pm >@@ -615,19 +615,29 @@ sub MarcRecordFromNewSuggestion { > my ($suggestion) = @_; > my $record = MARC::Record->new(); > >- my ($title_tag, $title_subfield) = GetMarcFromKohaField('biblio.title', ''); >- $record->append_fields( >- MARC::Field->new($title_tag, ' ', ' ', $title_subfield => $suggestion->{title}) >- ); >- >- my ($author_tag, $author_subfield) = GetMarcFromKohaField('biblio.author', ''); >- if ($record->field( $author_tag )) { >- $record->field( $author_tag )->add_subfields( $author_subfield => $suggestion->{author} ); >+ if (my $isbn = $suggestion->{isbn}) { >+ for my $field (qw(biblioitems.isbn biblioitems.issn)) { >+ my ($tag, $subfield) = GetMarcFromKohaField($field, ''); >+ $record->append_fields( >+ MARC::Field->new($tag, ' ', ' ', $subfield => $isbn) >+ ); >+ } > } > else { >+ my ($title_tag, $title_subfield) = GetMarcFromKohaField('biblio.title', ''); > $record->append_fields( >- MARC::Field->new($author_tag, ' ', ' ', $author_subfield => $suggestion->{author}) >+ MARC::Field->new($title_tag, ' ', ' ', $title_subfield => $suggestion->{title}) > ); >+ >+ my ($author_tag, $author_subfield) = GetMarcFromKohaField('biblio.author', ''); >+ if ($record->field( $author_tag )) { >+ $record->field( $author_tag )->add_subfields( $author_subfield => $suggestion->{author} ); >+ } >+ else { >+ $record->append_fields( >+ MARC::Field->new($author_tag, ' ', ' ', $author_subfield => $suggestion->{author}) >+ ); >+ } > } > > my ($it_tag, $it_subfield) = GetMarcFromKohaField('biblioitems.itemtype', ''); >diff --git a/suggestion/suggestion.pl b/suggestion/suggestion.pl >index 12eb39f017..6bea518b0e 100755 >--- a/suggestion/suggestion.pl >+++ b/suggestion/suggestion.pl >@@ -132,6 +132,7 @@ if ( $op =~ /save/i ) { > title => $suggestion_only->{title}, > author => $suggestion_only->{author}, > itemtype => $suggestion_only->{itemtype}, >+ isbn => $suggestion_only->{isbn}, > }); > > my $manager = Koha::Patrons->find( $suggestion_only->{managedby} ); >diff --git a/t/db_dependent/Suggestions.t b/t/db_dependent/Suggestions.t >index 9093cfc57d..b0e810804b 100755 >--- a/t/db_dependent/Suggestions.t >+++ b/t/db_dependent/Suggestions.t >@@ -648,4 +648,26 @@ subtest 'ModSuggestion should work on suggestions without a suggester' => sub { > is( $suggestion->{note}, "Test note", "ModSuggestion works on suggestions without a suggester" ); > }; > >+subtest 'Suggestion with ISBN' => sub { >+ my $suggestion_with_isbn = { >+ isbn => '1940997232', >+ title => "The Clouds", >+ author => "Aristophanes", >+ }; >+ my $record = MarcRecordFromNewSuggestion( $suggestion_with_isbn ); >+ is("MARC::Record", ref($record), "MarcRecordFromNewSuggestion should return a MARC::Record object"); >+ >+ my ($isbn_tag, $isbn_subfield) = C4::Biblio::GetMarcFromKohaField('biblioitems.isbn', ''); >+ is($record->field( $isbn_tag )->subfield( $isbn_subfield ), "1940997232", "ISBN Record from suggestion ISBN should be '1940997232'"); >+ >+ my ($issn_tag, $issn_subfield) = C4::Biblio::GetMarcFromKohaField('biblioitems.issn', ''); >+ is($record->field( $issn_tag )->subfield( $issn_subfield ), "1940997232", "ISSN Record from suggestion ISBN should also be '1940997232'"); >+ >+ my ($title_tag, $title_subfield) = C4::Biblio::GetMarcFromKohaField('biblio.title', ''); >+ is($record->field( $title_tag), undef, "Record from suggestion title should be empty"); >+ >+ my ($author_tag, $author_subfield) = C4::Biblio::GetMarcFromKohaField('biblio.author', ''); >+ is($record->field( $author_tag), undef, "Record from suggestion author should be emtpy"); >+} >+ > $schema->storage->txn_rollback; >-- >2.20.1
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 30195
:
131731
|
134923
|
134924
|
134925
|
135264
|
135265
|
135474
|
135475
|
135476