Bug 20363: (bug 16966 follow-up) better messages handling

User views the "Your privacy" -page, it shows "No reading history to
delete", even when the user has history.

Test plan:
- Turn OPACPrivacy on
- Go to opac-privacy.pl
- Click the "Immediate deletion button" to delete the reading history
=> If the patron has reading history you must get "Your reading history has been deleted."
Otherwise "No reading history to delete"

Note that this patch reintroduce the "something went wrong" message if
the deletion failed for whatever reason.

Signed-off-by: David Bourgault <david.bourgault@inlibro.com>

Signed-off-by: Katrin Fischer <katrin.fischer.83@web.de>

Signed-off-by: Jonathan Druart <jonathan.druart@bugs.koha-community.org>
This commit is contained in:
Jonathan Druart 2018-03-23 13:58:24 -03:00
parent 2edc7a2240
commit 0a49e3bf92
2 changed files with 10 additions and 3 deletions

View file

@ -27,7 +27,9 @@
[% IF deleted %] [% IF deleted %]
<div class="alert alert-success">Your reading history has been deleted.</div> <div class="alert alert-success">Your reading history has been deleted.</div>
[% ELSE %] [% ELSIF history_not_deleted %]
<div class="alert">The deletion of your reading history failed, because there is a problem with the configuration of this feature. Please help to fix the system by informing your library of this error</div>
[% ELSIF nothing_to_delete %]
<div class="alert">No reading history to delete</div> <div class="alert">No reading history to delete</div>
[% END %] [% END %]

View file

@ -63,8 +63,13 @@ elsif ( $op eq "delete_record" ) {
my $rows = eval { my $rows = eval {
Koha::Patrons->search({ 'me.borrowernumber' => $borrowernumber })->anonymise_issue_history; Koha::Patrons->search({ 'me.borrowernumber' => $borrowernumber })->anonymise_issue_history;
}; };
$rows = $@ ? 0 : int($rows); $template->param(
$template->param( 'deleted' => $rows ); (
$@ ? ( history_not_deleted => 1 )
: $rows ? ( deleted => int($rows) )
: ( nothing_to_delete => 1 )
)
);
} }
# get borrower privacy .... # get borrower privacy ....