Bugzilla – Attachment 179488 Details for
Bug 30255
Allow skipping "list" step for record batch modification/deletion
Home
|
New
|
Browse
|
Search
|
[?]
|
Reports
|
Help
|
New Account
|
Log In
[x]
|
Forgot Password
Login:
[x]
[patch]
Bug 30255: Make tidy
Bug-30255-Make-tidy.patch (text/plain), 11.03 KB, created by
David Gustafsson
on 2025-03-19 15:57:42 UTC
(
hide
)
Description:
Bug 30255: Make tidy
Filename:
MIME Type:
Creator:
David Gustafsson
Created:
2025-03-19 15:57:42 UTC
Size:
11.03 KB
patch
obsolete
>From 5a560d2129df327e3145e6fe0fc9213b7f0018e0 Mon Sep 17 00:00:00 2001 >From: David Gustafsson <david.gustafsson@ub.gu.se> >Date: Wed, 19 Mar 2025 16:54:47 +0100 >Subject: [PATCH] Bug 30255: Make tidy > >--- > .../tools/batch_record_modification.tt | 4 +- > tools/batch_delete_records.pl | 59 +++++++++++-------- > tools/batch_record_modification.pl | 49 +++++++-------- > 3 files changed, 59 insertions(+), 53 deletions(-) > >diff --git a/koha-tmpl/intranet-tmpl/prog/en/modules/tools/batch_record_modification.tt b/koha-tmpl/intranet-tmpl/prog/en/modules/tools/batch_record_modification.tt >index bdd741f3cdb..b8c9f0a2170 100644 >--- a/koha-tmpl/intranet-tmpl/prog/en/modules/tools/batch_record_modification.tt >+++ b/koha-tmpl/intranet-tmpl/prog/en/modules/tools/batch_record_modification.tt >@@ -171,9 +171,7 @@ > </ol> > </fieldset> > <fieldset class="brief" id="modify_all_hint" style="display: none;"> >- <div class="hint"> >- This will perform the modifications directly, without a confirmation step. >- </div> >+ <div class="hint"> This will perform the modifications directly, without a confirmation step. </div> > </fieldset> > <fieldset class="action"> > <input type="hidden" name="op" value="cud-list" /> >diff --git a/tools/batch_delete_records.pl b/tools/batch_delete_records.pl >index cf0ef012b2a..3f58b1398f1 100755 >--- a/tools/batch_delete_records.pl >+++ b/tools/batch_delete_records.pl >@@ -60,22 +60,22 @@ my $enqueue_job = sub { > > try { > my $params = { >- record_ids => $record_ids, >+ record_ids => $record_ids, > }; > > my $job_id = >- $recordtype eq 'biblio' >- ? Koha::BackgroundJob::BatchDeleteBiblio->new->enqueue($params) >- : Koha::BackgroundJob::BatchDeleteAuthority->new->enqueue($params); >+ $recordtype eq 'biblio' >+ ? Koha::BackgroundJob::BatchDeleteBiblio->new->enqueue($params) >+ : Koha::BackgroundJob::BatchDeleteAuthority->new->enqueue($params); > > $template->param( >- op => 'enqueued', >+ op => 'enqueued', > job_id => $job_id, > ); > } catch { > push @messages, { >- type => 'error', >- code => 'cannot_enqueue_job', >+ type => 'error', >+ code => 'cannot_enqueue_job', > error => $_, > }; > $template->param( view => 'errors' ); >@@ -83,6 +83,7 @@ my $enqueue_job = sub { > }; > > if ( $op eq 'form' ) { >+ > # Display the form > $template->param( > op => 'form', >@@ -94,6 +95,7 @@ if ( $op eq 'form' ) { > ) > ); > } elsif ( $op eq 'cud-list' || $op eq 'delete_all' ) { >+ > # List all records to process > my @record_ids; > if ( my $bib_list = $input->param('bib_list') ) { >@@ -102,6 +104,7 @@ if ( $op eq 'form' ) { > @record_ids = split /\//, $bib_list; > $recordtype = 'biblio'; > } elsif ( my $uploadfile = $input->param('uploadfile') ) { >+ > # A file of id is given > binmode $uploadfile, ':encoding(UTF-8)'; > while ( my $content = <$uploadfile> ) { >@@ -117,30 +120,32 @@ if ( $op eq 'form' ) { > push @record_ids, $biblionumber; > } > } else { >+ > # The user enters manually the list of id > push @record_ids, split( /\s\n/, scalar $input->param('recordnumber_list') ); > } > if ( $op eq 'delete_all' ) { >- $enqueue_job->(\@record_ids, $recordtype); >- } >- else { >+ $enqueue_job->( \@record_ids, $recordtype ); >+ } else { > for my $record_id ( uniq @record_ids ) { > if ( $recordtype eq 'biblio' ) { >+ > # Retrieve biblio information >- my $biblio_object = Koha::Biblios->find( $record_id ); >- unless ( $biblio_object ) { >+ my $biblio_object = Koha::Biblios->find($record_id); >+ unless ($biblio_object) { > push @messages, { >- type => 'warning', >- code => 'biblio_not_exists', >+ type => 'warning', >+ code => 'biblio_not_exists', > biblionumber => $record_id, > }; > next; > } > my $biblio = $biblio_object->unblessed; > my $record = $biblio_object->metadata->record; >- $biblio->{itemnumbers} = [Koha::Items->search({ biblionumber => $record_id })->get_column('itemnumber')]; >- $biblio->{holds_count} = $biblio_object->holds->count; >- $biblio->{issues_count} = C4::Biblio::CountItemsIssued( $record_id ); >+ $biblio->{itemnumbers} = >+ [ Koha::Items->search( { biblionumber => $record_id } )->get_column('itemnumber') ]; >+ $biblio->{holds_count} = $biblio_object->holds->count; >+ $biblio->{issues_count} = C4::Biblio::CountItemsIssued($record_id); > $biblio->{subscriptions_count} = $biblio_object->subscriptions->count; > > # Respect skip_open_orders >@@ -151,34 +156,36 @@ if ( $op eq 'form' ) { > > push @records, $biblio; > } else { >+ > # Retrieve authority information >- my $authority = C4::AuthoritiesMarc::GetAuthority( $record_id ); >- unless ( $authority ) { >+ my $authority = C4::AuthoritiesMarc::GetAuthority($record_id); >+ unless ($authority) { > push @messages, { >- type => 'warning', >- code => 'authority_not_exists', >+ type => 'warning', >+ code => 'authority_not_exists', > authid => $record_id, > }; > next; > } > > $authority = { >- authid => $record_id, >- summary => C4::AuthoritiesMarc::BuildSummary( $authority, $record_id ), >- count_usage => Koha::Authorities->get_usage_count({ authid => $record_id }), >+ authid => $record_id, >+ summary => C4::AuthoritiesMarc::BuildSummary( $authority, $record_id ), >+ count_usage => Koha::Authorities->get_usage_count( { authid => $record_id } ), > }; > push @records, $authority; > } > $template->param( > records => \@records, >- op => 'list', >+ op => 'list', > ); > } > } > } elsif ( $op eq 'cud-delete' ) { >+ > # We want to delete selected records! > my @record_ids = $input->multi_param('record_id'); >- $enqueue_job->(\@record_ids, $recordtype); >+ $enqueue_job->( \@record_ids, $recordtype ); > } > > $template->param( >diff --git a/tools/batch_record_modification.pl b/tools/batch_record_modification.pl >index 32a63bdea14..d8a2bf85f7d 100755 >--- a/tools/batch_record_modification.pl >+++ b/tools/batch_record_modification.pl >@@ -55,11 +55,10 @@ my ( $template, $loggedinuser, $cookie ) = get_template_and_user( > } > ); > >- > my $enqueue_job = sub { > my ( $record_ids, $recordtype ) = @_; > try { >- my $patron = Koha::Patrons->find( $loggedinuser ); >+ my $patron = Koha::Patrons->find($loggedinuser); > my $params = { > mmtid => $mmtid, > record_ids => $record_ids, >@@ -71,18 +70,18 @@ my $enqueue_job = sub { > }; > > my $job_id = >- $recordtype eq 'biblio' >- ? Koha::BackgroundJob::BatchUpdateBiblio->new->enqueue($params) >- : Koha::BackgroundJob::BatchUpdateAuthority->new->enqueue($params); >+ $recordtype eq 'biblio' >+ ? Koha::BackgroundJob::BatchUpdateBiblio->new->enqueue($params) >+ : Koha::BackgroundJob::BatchUpdateAuthority->new->enqueue($params); > > $template->param( >- view => 'enqueued', >+ view => 'enqueued', > job_id => $job_id, > ); > } catch { > push @messages, { >- type => 'error', >- code => 'cannot_enqueue_job', >+ type => 'error', >+ code => 'cannot_enqueue_job', > error => $_, > }; > $template->param( view => 'errors' ); >@@ -126,7 +125,7 @@ if ( $op eq 'form' ) { > ] > ) > ); >-} elsif ( $op eq 'cud-list' || $op eq 'modify_all') { >+} elsif ( $op eq 'cud-list' || $op eq 'modify_all' ) { > > # List all records to process > my ( @records, @record_ids ); >@@ -158,50 +157,52 @@ if ( $op eq 'form' ) { > } > > if ( $op eq 'modify_all' ) { >- $enqueue_job->(\@record_ids, $recordtype); >- } >- else { >+ $enqueue_job->( \@record_ids, $recordtype ); >+ } else { > for my $record_id ( uniq @record_ids ) { > if ( $recordtype eq 'biblio' ) { >+ > # Retrieve biblio information >- my $biblio = Koha::Biblios->find( $record_id ); >- unless ( $biblio ) { >+ my $biblio = Koha::Biblios->find($record_id); >+ unless ($biblio) { > push @messages, { >- type => 'warning', >- code => 'biblio_not_exists', >+ type => 'warning', >+ code => 'biblio_not_exists', > biblionumber => $record_id, > }; > next; > } > push @records, $biblio; > } else { >+ > # Retrieve authority information >- my $authority = Koha::MetadataRecord::Authority->get_from_authid( $record_id ); >- unless ( $authority ) { >+ my $authority = Koha::MetadataRecord::Authority->get_from_authid($record_id); >+ unless ($authority) { > push @messages, { >- type => 'warning', >- code => 'authority_not_exists', >+ type => 'warning', >+ code => 'authority_not_exists', > authid => $record_id, > }; > next; > } > > push @records, { >- authid => $record_id, >+ authid => $record_id, > summary => C4::AuthoritiesMarc::BuildSummary( $authority->record, $record_id ), > }; > } > $template->param( > records => \@records, >- mmtid => $mmtid, >- view => 'list', >+ mmtid => $mmtid, >+ view => 'list', > ); > } > } > } elsif ( $op eq 'cud-modify' ) { >+ > # We want to modify selected records! > my @record_ids = $input->multi_param('record_id'); >- $enqueue_job->(\@record_ids, $recordtype); >+ $enqueue_job->( \@record_ids, $recordtype ); > } > > $template->param( >-- >2.34.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 30255
:
131527
|
151289
|
151382
|
162547
|
162603
|
178175
|
178176
|
179486
|
179487
| 179488