fixed some bugs in circulate to get the noncat stuff working
authorerickson <erickson@dcc99617-32d9-48b4-a31d-7c20da2025e4>
Fri, 27 Jan 2006 17:40:38 +0000 (17:40 +0000)
committererickson <erickson@dcc99617-32d9-48b4-a31d-7c20da2025e4>
Fri, 27 Jan 2006 17:40:38 +0000 (17:40 +0000)
adding a new checkout.pl script to test permit and checkout of regular and noncat items

git-svn-id: svn://svn.open-ils.org/ILS/trunk@2863 dcc99617-32d9-48b4-a31d-7c20da2025e4

Open-ILS/src/perlmods/OpenILS/Application/Circ/Circulate.pm
Open-ILS/src/support-scripts/oils_header.pl
Open-ILS/src/support-scripts/test-scripts/checkout.pl [new file with mode: 0755]

index 54b55a6..b269021 100644 (file)
@@ -153,10 +153,10 @@ sub _doctor_circ_objects {
        $patron->home_ou( $apputils->fetch_org_unit( $patron->home_ou ) );
 
        # set the copy status to a status name
-       $copy->status( _get_copy_status( $copy, $ctx->{copy_statuses} ) );
+       $copy->status( _get_copy_status( $copy, $ctx->{copy_statuses} ) ) if $copy;
 
        # set the copy location to the location object
-       $copy->location( _get_copy_location( $copy, $ctx->{copy_locations} ) );
+       $copy->location( _get_copy_location( $copy, $ctx->{copy_locations} ) ) if $copy;
 
 }
 
@@ -268,8 +268,6 @@ sub permit_circ {
 
        my $barcode             = $params{barcode};
        my $patronid    = $params{patron};
-       my $isrenew             = $params{renew};
-       my $noncat              = $params{noncat};
 
        my ( $requestor, $patron, $ctx, $evt );
 
@@ -291,11 +289,12 @@ sub permit_circ {
                fetch_patron_circ_summary       => 1,
                fetch_copy_statuses                     => 1, 
                fetch_copy_locations                    => 1, 
-               isrenew                                                 => ($isrenew) ? 1 : 0,
-               noncat                                                  => $noncat,
+               isrenew                                                 => ($params{renew}) ? 1 : 0,
+               noncat                                                  => $params{noncat},
                );
        return $evt if $evt;
 
+       $ctx->{noncat_type} = $params{noncat_type};
        return _run_permit_scripts($ctx);
 }
 
@@ -308,7 +307,7 @@ sub _run_permit_scripts {
        my $ctx                 = shift;
        my $runner              = $ctx->{runner};
        my $patronid    = $ctx->{patron}->id;
-       my $barcode             = $ctx->{copy}->barcode;
+       my $barcode             = ($ctx->{copy}) ? $ctx->{copy}->barcode : undef;
 
        $runner->load($scripts{circ_permit_patron});
        $runner->run or throw OpenSRF::EX::ERROR ("Circ Permit Patron Script Died: $@");
index 1d80e85..6584c01 100755 (executable)
@@ -136,7 +136,7 @@ sub oils_login {
 
        my $response = $apputils->simplereq( $AUTH, 
                'open-ils.auth.authenticate.complete', $username, 
-               md5_hex($seed . md5_hex($password)));
+               md5_hex($seed . md5_hex($password)), "staff");
        err("No auth response returned on login") unless $response;
 
        oils_event_die($response);
@@ -146,6 +146,16 @@ sub oils_login {
        return $authtoken;
 }
 
+
+#----------------------------------------------------------------
+# Destroys the login session on the server
+#----------------------------------------------------------------
+sub oils_logout {
+       $apputils->simplereq(
+               'open-ils.auth',
+               'open-ils.auth.session.delete', $authtoken );
+}
+
 #----------------------------------------------------------------
 # Fetches the user object and sets the global $user var
 #----------------------------------------------------------------
diff --git a/Open-ILS/src/support-scripts/test-scripts/checkout.pl b/Open-ILS/src/support-scripts/test-scripts/checkout.pl
new file mode 100755 (executable)
index 0000000..61417e2
--- /dev/null
@@ -0,0 +1,57 @@
+#!/usr/bin/perl
+
+#----------------------------------------------------------------
+# Code for testing the container API
+#----------------------------------------------------------------
+
+require '../oils_header.pl';
+use vars qw/ $apputils $memcache $user $authtoken $authtime /;
+use strict; use warnings;
+
+err("usage: $0 <config> <oils_login_username> ".
+       " <oils_login_password> <patronid> <copy_barcode> [<type>]\n".
+       "Where <type> is one of:\n".
+       "\t'permit' to run the permit only\n".
+       "\t'noncat_permit' to run the permit script against a noncat item\n".
+       "\t'noncat' to check out a noncat item\n".
+       "\tblahk to do a regular checkout\n" ) unless $ARGV[4];
+
+my $config             = shift; 
+my $username   = shift;
+my $password   = shift;
+my $patronid   = shift;
+my $barcode            = shift;
+my $type                       = shift;
+
+my $method = 'open-ils.circ.checkout_permit_';
+
+sub go {
+       osrf_connect($config);
+       oils_login($username, $password);
+       do_permit($patronid, $barcode, $type =~ /noncat/ ); 
+       do_checkout($patronid, $barcode, $type =~ /noncat/ ) unless ($type =~ /permit/);
+       oils_logout();
+}
+
+go();
+
+#----------------------------------------------------------------
+
+
+sub do_permit {
+       my( $patronid, $barcode, $noncat ) = @_;
+
+       my @args = ( $authtoken, 'patron', $patronid );
+       push(@args, ('barcode', $barcode)) unless $noncat;
+       push(@args, ('noncat', 1)) if $noncat;
+
+       my $resp = simplereq( 
+               CIRC(), 'open-ils.circ.permit_checkout_', @args );
+       
+       oils_event_die($resp);
+       printl("Permit succeeded for patron $patronid");
+}
+
+sub do_checkout {
+}
+