$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;
}
my $barcode = $params{barcode};
my $patronid = $params{patron};
- my $isrenew = $params{renew};
- my $noncat = $params{noncat};
my ( $requestor, $patron, $ctx, $evt );
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);
}
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: $@");
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);
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
#----------------------------------------------------------------
--- /dev/null
+#!/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 {
+}
+