Tried a couple of varieties of checkout as staff, not working
authorkenstir <kenstir@gmail.com>
Wed, 4 Nov 2020 00:42:15 +0000 (00:42 +0000)
committerkenstir <kenstir@gmail.com>
Wed, 4 Nov 2020 00:42:15 +0000 (00:42 +0000)
Suggestions I got during hackaway:
* try .override
* put selfcheck logic into normal checkout flow, as is done with renew
  (i.e. a user can renew their own items without special permissions)

Open-ILS/src/perlmods/lib/OpenILS/Application/Selfcheck.pm

index 0562938..8b8c7e6 100644 (file)
@@ -30,6 +30,8 @@ sub child_init {
     $logger->info("child_init: kcxxx:$kcxxx");
 }
 
+#----------------------------------------------------------------------
+
 sub exists {
     return 1;
 }
@@ -46,6 +48,8 @@ __PACKAGE__->register_method(
     }
 );
 
+#----------------------------------------------------------------------
+
 sub xyzzy {
     my ($self, $conn, $authtoken, $id) = @_;
 
@@ -54,13 +58,13 @@ sub xyzzy {
 
     my $org = $e->requestor->ws_ou;
     $logger->info("org:$org");
-    $logger->info("e:".Dumper($e));
+    #$logger->info("e:".Dumper($e));
 
     return new OpenILS::Event("SELFCHECK_NOT_ALLOWED") unless ($U->is_true(
         $U->ou_ancestor_setting_value($org, 'circ.selfcheck')
     ));
 
-    return $org;
+    return {"org" => $e->requestor->ws_ou, "patronid" => $e->requestor->id};
 }
 __PACKAGE__->register_method(
     method => "xyzzy",
@@ -70,10 +74,14 @@ __PACKAGE__->register_method(
             {type => 'string', desc => 'Authentication token'},
             {type => 'number', desc => 'ID'},
         ],
-        return => { desc => 'Test junk' }
+        return => {
+            desc => 'Test junk'
+        }
     }
 );
 
+#----------------------------------------------------------------------
+
 sub checkout {
     my ($self, $conn, $authtoken, $barcode) = @_;
 
@@ -87,7 +95,7 @@ sub checkout {
 
     my $r = $U->simplereq(
         'open-ils.circ',
-        'open-ils.circ.checkout',
+        'open-ils.circ.checkout.full',
         $authtoken,
         { barcode => $barcode, patron => $e->requestor->id });
 
@@ -95,7 +103,43 @@ sub checkout {
 }
 __PACKAGE__->register_method(
     method => "checkout",
-    api_name => "open-ils.selfcheck.checkout",
+    api_name => "open-ils.selfcheck.checkout.override",
+    signature => {
+        params => [
+            {type => 'string', desc => 'Authentication token'},
+            {type => 'string', desc => 'barcode'},
+        ],
+        return => { desc => 'Checkout item by barcode' }
+    }
+);
+
+#----------------------------------------------------------------------
+
+sub checkout2 {
+    my ($self, $conn, $authtoken, $barcode) = @_;
+
+    my $e = new_editor(xact => 1, authtoken => $authtoken);
+    return $e->die_event unless $e->checkauth;
+
+    my $org = $e->requestor->ws_ou;
+    return new OpenILS::Event("SELFCHECK_NOT_ALLOWED") unless ($U->is_true(
+        $U->ou_ancestor_setting_value($org, 'circ.selfcheck')
+    ));
+
+    my $circ_sess = OpenSRF::AppSession->connect('open-ils.circ');
+    my $req = $circ_sess->request(
+        'open-ils.circ.checkout.full.override',
+        $authtoken,
+        { barcode => $barcode, patron => $e->requestor->id });
+    
+    $conn->respond($req->gather(1));
+    $circ_sess->disconnect;
+
+    return;
+}
+__PACKAGE__->register_method(
+    method => "checkout2",
+    api_name => "open-ils.selfcheck.checkout2",
     signature => {
         params => [
             {type => 'string', desc => 'Authentication token'},