LP#1312699: Minor modifications to patron checkout history deletions
authorJake Litrell <jake@masslnc.org>
Tue, 1 Mar 2016 22:22:28 +0000 (17:22 -0500)
committerBen Shum <ben@evergreener.net>
Wed, 2 Mar 2016 06:01:48 +0000 (01:01 -0500)
Minor modifications to make patron checkout history deletions work with
the new table.  open-ils.actor.history.circ.clear
extended to take an optional list of circ_ids, to limit what's deleted
from the history.

Signed-off-by: Jake Litrell <jake@masslnc.org>
Signed-off-by: Kathy Lussier <klussier@masslnc.org>
Open-ILS/src/perlmods/lib/OpenILS/Application/Actor.pm
Open-ILS/src/perlmods/lib/OpenILS/WWW/EGCatLoader/Account.pm
Open-ILS/src/templates/opac/myopac/circ_history.tt2

index 2bb874b..873ad3b 100644 (file)
@@ -4217,6 +4217,7 @@ __PACKAGE__->register_method(
         desc   => 'Delete all user circ history entries for the calling user',
         params => [
             { desc => 'Authentication token',  type => 'string'},
+            { desc => "Options hash. 'circ_ids' is an arrayref of circulation IDs to delete", type => 'object' },
         ],
         return => {
             desc => q/1 on success, event on error/,
@@ -4278,8 +4279,12 @@ sub user_circ_history {
         $limits{limit} = $options->{limit} if defined $options->{limit};
     }
 
+    my $circ_id_list = $options->{circ_ids} ? $options->{circ_ids} : undef;
+
     my $circs = $e->search_action_user_circ_history([
-        {usr => $e->requestor->id},
+        {   usr => $e->requestor->id,
+            id  => {'in' => $circ_id_list},
+        },
         {   # order newest to oldest by default
             order_by => {auch => 'xact_start DESC'},
             %limits
index 9de2eec..945c9f2 100644 (file)
@@ -1544,7 +1544,6 @@ sub handle_circ_renew {
     return @responses;
 }
 
-
 sub load_myopac_circs {
     my $self = shift;
     my $e = $self->editor;
@@ -1652,31 +1651,26 @@ sub fetch_user_circ_history {
 }
 
 sub handle_circ_update {
-    my $self = shift;
-    my $action = shift;
+    my $self     = shift;
+    my $action   = shift;
     my $circ_ids = shift;
-    my $e = $self->editor;
-    my $url;
 
-    my @circ_ids = ($circ_ids) ? @$circ_ids : $self->cgi->param('circ_id'); # for non-_all actions
+    my $circ_ids //= [$self->cgi->param('circ_id')];
 
-    my $cstore_ses = OpenSRF::AppSession->create('open-ils.cstore');
-    $cstore_ses->connect();
-    $cstore_ses->request('open-ils.cstore.transaction.begin')->gather(1);
+    if ($action =~ /delete/) {
+        my $options = {
+            circ_ids => $circ_ids,
+        };
 
-    if($action =~ /delete/) {
-        for my $circ_id (@circ_ids) {
-            my $circ = $cstore_ses->request(
-                'open-ils.cstore.direct.action.circulation.retrieve', $circ_id)->gather(1);
-            $circ->hide_from_usr_history(1);
-            my $resp = $cstore_ses->request(
-                'open-ils.cstore.direct.action.circulation.update', $circ)->gather(1);
-        }
+        $U->simplereq(
+            'open-ils.actor',
+            'open-ils.actor.history.circ.clear',
+            $self->editor->authtoken,
+            $options
+        );
     }
 
-    $cstore_ses->request('open-ils.cstore.transaction.commit')->gather(1);
-    $cstore_ses->disconnect();
-    return undef;
+    return;
 }
 
 # TODO: action.usr_visible_holds does not return cancelled holds.  Should it?
index abe007d..675dff9 100644 (file)
                         </td>
                         <td>[% circ.circ.target_copy.barcode | html %]</td>
                         <td>[% circ.circ.target_copy.call_number.label | html %]</td>
-        </form>
                     </tr>
                 [% END %]
             </tbody>
         </table>
     </div>
+    </form>
     [% END %]
 </div>
 [% END %]