Bugzilla – Attachment 53139 Details for
Bug 9259
Delete marc batches from staged marc management
Home
|
New
|
Browse
|
Search
|
[?]
|
Reports
|
Help
|
New Account
|
Log In
[x]
|
Forgot Password
Login:
[x]
[patch]
Bug 9259: Ability to delete a staged file once it has been cleaned
Bug-9259-Ability-to-delete-a-staged-file-once-it-h.patch (text/plain), 7.43 KB, created by
Jonathan Druart
on 2016-07-06 15:58:14 UTC
(
hide
)
Description:
Bug 9259: Ability to delete a staged file once it has been cleaned
Filename:
MIME Type:
Creator:
Jonathan Druart
Created:
2016-07-06 15:58:14 UTC
Size:
7.43 KB
patch
obsolete
>From 07fc0e00966849617f773bedc13f11feaca6b3ae Mon Sep 17 00:00:00 2001 >From: Aleisha <aleishaamohia@hotmail.com> >Date: Tue, 29 Mar 2016 00:04:36 +0000 >Subject: [PATCH] Bug 9259: Ability to delete a staged file once it has been > cleaned > >To test: >1) Go to Tools -> Staged MARC Management and clean a file. If you have no files to clean, go to 'Stage MARC for import' and upload one to clean following the necessary steps. >2) Confirm that once the file has been cleaned, the Action column now shows a Delete button. Confirm this button only shows for cleaned files. >3) Click the Delete button. >4) Confirm that clicking Cancel exits the pop-up message and does not delete the file. >5) Confirm that clicking OK refreshes the list of staged records and the one you just deleted is no longer on it (has been deleted). You can confirm this by checking for the file in mysql (SELECT * FROM import_batches WHERE import_batch_id = X;) >6) Run prove -v t/db_dependent/ImportBatch.t (have written unit tests for CleanBatch and DeleteBatch) > >Sponsored-by: Catalyst IT >Signed-off-by: Liz Rea <liz@catalyst.net.nz> >Catalyst sign off, so needs another one but YAY this is great. > >Signed-off-by: Nick Clemens <nick@bywatersolutions.com> > >Signed-off-by: Jonathan Druart <jonathan.druart@bugs.koha-community.org> >--- > C4/ImportBatch.pm | 19 +++++++++++++ > .../prog/en/modules/tools/manage-marc-import.tt | 15 +++++++++-- > t/db_dependent/ImportBatch.t | 31 +++++++++++++++++++++- > tools/manage-marc-import.pl | 6 +++++ > 4 files changed, 68 insertions(+), 3 deletions(-) > >diff --git a/C4/ImportBatch.pm b/C4/ImportBatch.pm >index 1d387e1..4d63e8d 100644 >--- a/C4/ImportBatch.pm >+++ b/C4/ImportBatch.pm >@@ -53,6 +53,7 @@ BEGIN { > BatchCommitRecords > BatchRevertRecords > CleanBatch >+ DeleteBatch > > GetAllImportBatches > GetStagedWebserviceBatches >@@ -959,6 +960,24 @@ sub CleanBatch { > SetImportBatchStatus($batch_id, 'cleaned'); > } > >+=head2 DeleteBatch >+ >+ DeleteBatch($batch_id) >+ >+Deletes the record from the database. This can only be done >+once the batch has been cleaned. >+ >+=cut >+ >+sub DeleteBatch { >+ my $batch_id = shift; >+ return unless defined $batch_id; >+ >+ my $dbh = C4::Context->dbh; >+ my $sth = $dbh->prepare('DELETE FROM import_batches WHERE import_batch_id = ?'); >+ $sth->execute( $batch_id ); >+} >+ > =head2 GetAllImportBatches > > my $results = GetAllImportBatches(); >diff --git a/koha-tmpl/intranet-tmpl/prog/en/modules/tools/manage-marc-import.tt b/koha-tmpl/intranet-tmpl/prog/en/modules/tools/manage-marc-import.tt >index 3a786e9..e6bf950 100644 >--- a/koha-tmpl/intranet-tmpl/prog/en/modules/tools/manage-marc-import.tt >+++ b/koha-tmpl/intranet-tmpl/prog/en/modules/tools/manage-marc-import.tt >@@ -39,6 +39,7 @@ > //<![CDATA[ > var MSG_CONFIRM_CLEAN = _("Clear all reservoir records staged in this batch? This cannot be undone."); > var MSG_CONFIRM_UNDO_IMPORT = _("Are you sure you want to undo the import of this batch into the catalog?"); >+var MSG_CONFIRM_DELETE = _("Are you sure you want to permanently delete this batch?"); > > $(document).ready(function(){ > $("#staged-record-matching-rules select").change(function(){ >@@ -195,6 +196,10 @@ $(document).ready(function(){ > <div class="dialog message">Cleaned import batch #[% import_batch_id %]</div> > [% END %] > >+[% IF ( did_delete ) %] >+ <div class="dialog message">Import batch deleted successfully</div> >+[% END %] >+ > [% UNLESS ( batch_list ) %] > [% UNLESS ( batch_info ) %] > <div class="dialog message"> >@@ -449,11 +454,17 @@ Page > <td>[% batch_lis.upload_timestamp %]</td> > <td>[% batch_lis.num_records %]</td> > <td>[% batch_lis.num_items %][% IF ( batch_lis.num_items ) %] <a href="[% batch_lis.script_name %]?import_batch_id=[% batch_lis.import_batch_id %]&op=create_labels">(Create label batch)</a>[% END %]</td> >- <td>[% IF ( batch_lis.can_clean ) %] >+ <td class="actions">[% IF ( batch_lis.can_clean ) %] > <form method="post" action="[% batch_lis.script_name %]" name="clean_batch_[% batch_lis.import_batch_id %]" id="clean_batch_[% batch_lis.import_batch_id %]" > > <input type="hidden" name="import_batch_id" value="[% batch_lis.import_batch_id %]" /> > <input type="hidden" name="op" value="clean-batch" /> >- <button class="btn btn-small" onclick="return confirm(MSG_CONFIRM_CLEAN);">Clean</button> >+ <button class="btn btn-mini" onclick="return confirm(MSG_CONFIRM_CLEAN);"><i class="fa fa-eraser"></i> Clean</button> >+ </form> >+ [% ELSIF ( batch_lis.import_status == 'cleaned' ) %] >+ <form method="post" action="/cgi-bin/koha/tools/manage-marc-import.pl" name="delete_batch_[% batch_lis.import_batch_id %]" id="delete_batch_[% batch_lis.import_batch_id %]"> >+ <input type="hidden" name="import_batch_id" value="[% batch_lis.import_batch_id %]" /> >+ <input type="hidden" name="op" value="delete-batch" /> >+ <button class="btn btn-mini" onclick="return confirm(MSG_CONFIRM_DELETE);"><i class="fa fa-trash"></i> Delete</button> > </form> > [% END %] > </td> >diff --git a/t/db_dependent/ImportBatch.t b/t/db_dependent/ImportBatch.t >index 661cd33..8cb84ce 100644 >--- a/t/db_dependent/ImportBatch.t >+++ b/t/db_dependent/ImportBatch.t >@@ -4,7 +4,7 @@ use Modern::Perl; > > use C4::Context; > >-use Test::More tests => 7; >+use Test::More tests => 9; > > BEGIN { > use_ok('C4::ImportBatch'); >@@ -117,3 +117,32 @@ $original_record->delete_fields($original_record->field($item_tag)); #Remove ite > my $record_from_import_biblio_without_items = C4::ImportBatch::GetRecordFromImportBiblio( $import_record_id ); > $original_record->leader($record_from_import_biblio_without_items->leader()); > is_deeply( $record_from_import_biblio_without_items, $original_record, 'GetRecordFromImportBiblio should return the record without items by default' ); >+ >+# fresh data >+my $sample_import_batch3 = { >+ matcher_id => 3, >+ template_id => 3, >+ branchcode => 'QRT', >+ overlay_action => 'create_new', >+ nomatch_action => 'create_new', >+ item_action => 'always_add', >+ import_status => 'staged', >+ batch_type => 'z3950', >+ file_name => 'test.mrc', >+ comments => 'test', >+ record_type => 'auth', >+}; >+ >+my $id_import_batch3 = C4::ImportBatch::AddImportBatch($sample_import_batch3); >+ >+# Test CleanBatch >+C4::ImportBatch::CleanBatch( $id_import_batch3 ); >+my $batch3_clean = $dbh->do('SELECT * FROM import_records WHERE import_batch_id = "$id_import_batch3"'); >+is_deeply( $batch3_clean, "0E0", >+ "Batch 3 has been cleaned" ); >+ >+# Test DeleteBatch >+C4::ImportBatch::DeleteBatch( $id_import_batch3 ); >+my $batch3_results = $dbh->do('SELECT * FROM import_batches WHERE import_batch_id = "$id_import_batch3"'); >+is_deeply( $batch3_results, "0E0", # 0E0 == 0 >+ "Batch 3 has been deleted"); >diff --git a/tools/manage-marc-import.pl b/tools/manage-marc-import.pl >index b0d4f88..83abc91 100755 >--- a/tools/manage-marc-import.pl >+++ b/tools/manage-marc-import.pl >@@ -123,6 +123,12 @@ if ($op eq "") { > did_clean => 1, > import_batch_id => $import_batch_id, > ); >+} elsif ($op eq "delete-batch") { >+ DeleteBatch($import_batch_id); >+ import_batches_list($template, $offset, $results_per_page); >+ $template->param( >+ did_delete => 1, >+ ); > } elsif ($op eq "redo-matching") { > my $new_matcher_id = $input->param('new_matcher_id'); > my $current_matcher_id = $input->param('current_matcher_id'); >-- >2.8.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 9259
:
49609
|
49746
|
53007
|
53116
| 53139 |
53140