Bugzilla – Attachment 52899 Details for
Bug 15023
Allow patron anonymize/bulk delete tool to be limited by branch
Home
|
New
|
Browse
|
Search
|
[?]
|
Reports
|
Help
|
New Account
|
Log In
[x]
|
Forgot Password
Login:
[x]
[patch]
Bug 15023: Allow patron anonymize/bulk delete tool to be limited by branch
Bug-15023-Allow-patron-anonymizebulk-delete-tool-t.patch (text/plain), 8.03 KB, created by
Tomás Cohen Arazi (tcohen)
on 2016-06-27 15:26:18 UTC
(
hide
)
Description:
Bug 15023: Allow patron anonymize/bulk delete tool to be limited by branch
Filename:
MIME Type:
Creator:
Tomás Cohen Arazi (tcohen)
Created:
2016-06-27 15:26:18 UTC
Size:
8.03 KB
patch
obsolete
>From ffce3f1c9b705aad4dcfbd2e3567cbd8f857bfa7 Mon Sep 17 00:00:00 2001 >From: Tomas Cohen Arazi <tomascohen@theke.io> >Date: Mon, 27 Jun 2016 12:12:52 -0300 >Subject: [PATCH] Bug 15023: Allow patron anonymize/bulk delete tool to be > limited by branch > >This patch makes the bulk patron delete/anonymize functionality be limited >by branch. It does so by adding a branch selection dropdown and using the >already defined APIs for filtering by branch. > >It makes use of C4::Branches::onlymine for the IndependentBranches use case >and it adds a way to call it from the Branches template plugin. > >To test: >- Apply the patch >1) Have a superlibrarian user >- Go to Tools > Batch patron deletion/anonymization >=> SUCCESS: Verify you can pick a branch (or all of them) >- Try doing some operations >=> SUCCESS: Verify the selection is respected, and carried around all steps >2) Have a user with tools/delete_anonymize_patrons permissions >- Set IndependentBranches on >- Go to Tools > Batch patron deletion/anonymization >=> SUCCESS: It picks the librarian's branch and doesn't let us choose another one >- Try doing some operations >=> SUCCESS: Verify the user's branch is respected, and carried around all steps >- Sign off :-D > >Sponsored-by: VOKAL >--- > Koha/Template/Plugin/Branches.pm | 4 +++ > .../prog/en/modules/tools/cleanborrowers.tt | 38 ++++++++++++++++++++-- > tools/cleanborrowers.pl | 29 +++++++++++++---- > 3 files changed, 61 insertions(+), 10 deletions(-) > >diff --git a/Koha/Template/Plugin/Branches.pm b/Koha/Template/Plugin/Branches.pm >index 880b2c4..0b95e42 100644 >--- a/Koha/Template/Plugin/Branches.pm >+++ b/Koha/Template/Plugin/Branches.pm >@@ -54,6 +54,10 @@ sub GetURL { > return $b->{branchurl}; > } > >+sub OnlyMine { >+ return C4::Branch::onlymine; >+} >+ > sub all { > my ( $self, $params ) = @_; > my $selected = $params->{selected}; >diff --git a/koha-tmpl/intranet-tmpl/prog/en/modules/tools/cleanborrowers.tt b/koha-tmpl/intranet-tmpl/prog/en/modules/tools/cleanborrowers.tt >index 9e68141..ae7df4e 100644 >--- a/koha-tmpl/intranet-tmpl/prog/en/modules/tools/cleanborrowers.tt >+++ b/koha-tmpl/intranet-tmpl/prog/en/modules/tools/cleanborrowers.tt >@@ -1,5 +1,6 @@ > [% USE Koha %] > [% USE KohaDates %] >+[% USE Branches %] > [% INCLUDE 'doc-head-open.inc' %] > <title>Koha › Tools › Batch patron deletion/anonymization [% IF step == 2 %]› Confirm[% END %][% IF step == 3 %]› Finished[% END %]</title> > [% INCLUDE 'doc-head-close.inc' %] >@@ -37,6 +38,13 @@ > function checkForm2(form) { > return true; > } >+ >+ $(document).ready(function() { >+ $('#selectlibrary').find("input:submit").hide(); >+ $('#branch').change(function() { >+ $('#selectlibrary').submit(); >+ }); >+ }); > // ]]> > </script> > >@@ -52,13 +60,35 @@ > <div id="bd"> > <div id="yui-main"> > <div class="yui-b"> >+[% IF !Branches.OnlyMine %] >+ <form method="get" action="/cgi-bin/koha/tools/cleanborrowers.pl" id="selectlibrary"> >+ Select a library : >+ <select name="branch" id="branch" style="width:20em;"> >+ <option value="*">All libraries</option> >+ [% FOREACH branch IN Branches.all( selected => current_branch ) %] >+ [% IF branch.selected %] >+ <option value="[% branch.branchcode %]" selected="selected">[% branch.branchname %]</option> >+ [% ELSE %] >+ <option value="[% branch.branchcode %]">[% branch.branchname %]</option> >+ [% END %] >+ [% END %] >+ </select> >+ </form> >+ [% IF current_branch == '*' %] >+ <h1>Batch patron deletion/anonymization</h1> >+ [% ELSE %] >+ <h1>Batch patron deletion/anonymization for [% Branches.GetName( current_branch ) %]</h1> >+ [% END %] >+[% ELSE %] >+ <h1>Batch patron deletion/anonymization for [% Branches.GetName( Branches.GetLoggedInBranchcode ) %]</h1> >+[% END %] >+ >+[% IF step == 1 %] >+<!-- step 1 START --> > >-<h1>Batch patron deletion/anonymization</h1> > <div class="help"> > <p>This tool allows you to delete patrons and anonymize checkout history. For deleting patrons, any combination of limits can be used.</p> > </div> >-[% IF step == 1 %] >-<!-- step 1 START --> > <div id="step1"> > <form name="f1" onsubmit="return checkForm(this);" action="/cgi-bin/koha/tools/cleanborrowers.pl" method="post"> > <fieldset> >@@ -119,6 +149,7 @@ > > <!-- hidden here --> > <input type="hidden" name="step" value="2" /> >+ <input type="hidden" name="branch" value="[% current_branch %]" /> > </fieldset> > <fieldset class="action"><input type="submit" value="Next >>" /></fieldset> > </form> >@@ -162,6 +193,7 @@ > <input type="hidden" name="borrower_dateexpiry" value="[% borrower_dateexpiry | $KohaDates %]" /> > <input type="hidden" name="borrower_categorycode" value="[% borrower_categorycode %]" /> > <input type="hidden" name="patron_list_id" value="[% patron_list_id %]" /> >+ <input type="hidden" name="branch" value="[% current_branch %]" /> > </fieldset> > <fieldset class="action"><input type="submit" value="Finish" /> <a class="cancel" href="/cgi-bin/koha/tools/cleanborrowers.pl">Cancel</a></fieldset> > </form> >diff --git a/tools/cleanborrowers.pl b/tools/cleanborrowers.pl >index d108d53..df2196f 100755 >--- a/tools/cleanborrowers.pl >+++ b/tools/cleanborrowers.pl >@@ -31,9 +31,8 @@ This script allows to do 2 things. > > =cut > >-use strict; >+use Modern::Perl; > >-#use warnings; FIXME - Bug 2505 > use CGI qw ( -utf8 ); > use C4::Auth; > use C4::Output; >@@ -78,6 +77,9 @@ my ( $template, $loggedinuser, $cookie ) = get_template_and_user( > } > ); > >+my $branch = $params->{ branch } || '*'; >+$template->param( current_branch => $branch ); >+ > if ( $step == 2 ) { > > my %checkboxes = map { $_ => 1 } split /\0/, $params->{'checkbox'}; >@@ -90,6 +92,7 @@ if ( $step == 2 ) { > $borrower_dateexpiry, > $borrower_categorycode, > $patron_list_id, >+ $branch > ) > ); > } >@@ -97,13 +100,17 @@ if ( $step == 2 ) { > > my $members_to_anonymize; > if ( $checkboxes{issue} ) { >- $members_to_anonymize = GetBorrowersWithIssuesHistoryOlderThan($last_issue_date); >+ if ( $branch eq '*' ) { >+ $members_to_anonymize = GetBorrowersWithIssuesHistoryOlderThan($last_issue_date); >+ } else { >+ $members_to_anonymize = GetBorrowersWithIssuesHistoryOlderThan($last_issue_date, $branch); >+ } > } > > $template->param( > patrons_to_delete => $patrons_to_delete, > patrons_to_anonymize => $members_to_anonymize, >- patron_list_id => $patron_list_id, >+ patron_list_id => $patron_list_id > ); > } > >@@ -117,8 +124,11 @@ elsif ( $step == 3 ) { > if ($do_delete) { > my $patrons_to_delete = GetBorrowersToExpunge( > _get_selection_params( >- $not_borrowed_since, $borrower_dateexpiry, >- $borrower_categorycode, $patron_list_id >+ $not_borrowed_since, >+ $borrower_dateexpiry, >+ $borrower_categorycode, >+ $patron_list_id, >+ $branch > ) > ); > _skip_borrowers_with_nonzero_balance($patrons_to_delete); >@@ -183,7 +193,8 @@ sub _skip_borrowers_with_nonzero_balance { > } > > sub _get_selection_params { >- my ($not_borrowed_since, $borrower_dateexpiry, $borrower_categorycode, $patron_list_id) = @_; >+ my ($not_borrowed_since, $borrower_dateexpiry, >+ $borrower_categorycode, $patron_list_id, $branch) = @_; > > my $params = {}; > $params->{not_borrowed_since} = output_pref({ >@@ -199,5 +210,9 @@ sub _get_selection_params { > $params->{category_code} = $borrower_categorycode if $borrower_categorycode; > $params->{patron_list_id} = $patron_list_id if $patron_list_id; > >+ if ( defined $branch and $branch ne '*' ) { >+ $params->{ branchcode } = $branch; >+ } >+ > return $params; > }; >-- >2.9.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 15023
:
52899
|
52900
|
53463
|
53464
|
53735
|
53736