From 63761fe26e4b6a1625725b27a48efc0206cece39 Mon Sep 17 00:00:00 2001 From: erickson Date: Fri, 27 Jan 2006 17:40:38 +0000 Subject: [PATCH] fixed some bugs in circulate to get the noncat stuff working 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 --- .../OpenILS/Application/Circ/Circulate.pm | 13 ++--- Open-ILS/src/support-scripts/oils_header.pl | 12 +++- .../support-scripts/test-scripts/checkout.pl | 57 +++++++++++++++++++ 3 files changed, 74 insertions(+), 8 deletions(-) create mode 100755 Open-ILS/src/support-scripts/test-scripts/checkout.pl diff --git a/Open-ILS/src/perlmods/OpenILS/Application/Circ/Circulate.pm b/Open-ILS/src/perlmods/OpenILS/Application/Circ/Circulate.pm index 54b55a6e99..b269021b44 100644 --- a/Open-ILS/src/perlmods/OpenILS/Application/Circ/Circulate.pm +++ b/Open-ILS/src/perlmods/OpenILS/Application/Circ/Circulate.pm @@ -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: $@"); diff --git a/Open-ILS/src/support-scripts/oils_header.pl b/Open-ILS/src/support-scripts/oils_header.pl index 1d80e857d9..6584c01fbe 100755 --- a/Open-ILS/src/support-scripts/oils_header.pl +++ b/Open-ILS/src/support-scripts/oils_header.pl @@ -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 index 0000000000..61417e2beb --- /dev/null +++ b/Open-ILS/src/support-scripts/test-scripts/checkout.pl @@ -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 ". + " []\n". + "Where 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 { +} + -- 2.43.2