[open-ils-commits] r16598 - in trunk/Open-ILS/src/perlmods/OpenILS: . Application/Circ SIP SIP/Transaction (erickson)
svn at svn.open-ils.org
svn at svn.open-ils.org
Fri Jun 4 16:53:29 EDT 2010
Author: erickson
Date: 2010-06-04 16:53:24 -0400 (Fri, 04 Jun 2010)
New Revision: 16598
Modified:
trunk/Open-ILS/src/perlmods/OpenILS/Application/Circ/Circulate.pm
trunk/Open-ILS/src/perlmods/OpenILS/SIP.pm
trunk/Open-ILS/src/perlmods/OpenILS/SIP/Patron.pm
trunk/Open-ILS/src/perlmods/OpenILS/SIP/Transaction/Renew.pm
Log:
Experimental implementation: renewal, block, enable.
Add sip_renewal (not implemented), correct log message w/ join
Patron block message and patron enable
This adds code for enable, still experimental. It also adds the
client's block message to the patron alert, bracketed by <sip> tags.
The tags are necessary because enable has to be able to regexp out
the block alert message (including user-specified variable text).
Remove unused vars.
Whitespace cleanup and extra feedback data.
Return object on failure, not just 0
Signed-off-by: Joe Atzberger <atz at esilibrary.com>
Modified: trunk/Open-ILS/src/perlmods/OpenILS/Application/Circ/Circulate.pm
===================================================================
--- trunk/Open-ILS/src/perlmods/OpenILS/Application/Circ/Circulate.pm 2010-06-04 20:53:23 UTC (rev 16597)
+++ trunk/Open-ILS/src/perlmods/OpenILS/Application/Circ/Circulate.pm 2010-06-04 20:53:24 UTC (rev 16598)
@@ -40,12 +40,12 @@
$logger->error( "Missing circ script(s)" )
unless( $p and $c and $d and $f and $m and $pr );
- $scripts{circ_permit_patron} = $p;
- $scripts{circ_permit_copy} = $c;
- $scripts{circ_duration} = $d;
- $scripts{circ_recurring_fines}= $f;
- $scripts{circ_max_fines} = $m;
- $scripts{circ_permit_renew} = $pr;
+ $scripts{circ_permit_patron} = $p;
+ $scripts{circ_permit_copy} = $c;
+ $scripts{circ_duration} = $d;
+ $scripts{circ_recurring_fines} = $f;
+ $scripts{circ_max_fines} = $m;
+ $scripts{circ_permit_renew} = $pr;
$logger->debug(
"circulator: Loaded rules scripts for circ: " .
@@ -120,15 +120,15 @@
);
__PACKAGE__->register_method(
- method => "run_method",
- api_name => "open-ils.circ.checkin.override",
- signature => q/@see open-ils.circ.checkin/
+ method => "run_method",
+ api_name => "open-ils.circ.checkin.override",
+ signature => q/@see open-ils.circ.checkin/
);
__PACKAGE__->register_method(
- method => "run_method",
- api_name => "open-ils.circ.renew.override",
- signature => q/@see open-ils.circ.renew/,
+ method => "run_method",
+ api_name => "open-ils.circ.renew.override",
+ signature => q/@see open-ils.circ.renew/,
);
@@ -144,29 +144,28 @@
NOTES
__PACKAGE__->register_method(
- method => "run_method",
- api_name => "open-ils.circ.checkout.full");
+ method => "run_method",
+ api_name => "open-ils.circ.checkout.full"
+);
__PACKAGE__->register_method(
- method => "run_method",
- api_name => "open-ils.circ.checkout.full.override");
-
+ method => "run_method",
+ api_name => "open-ils.circ.checkout.full.override"
+);
__PACKAGE__->register_method(
- method => "run_method",
- api_name => "open-ils.circ.reservation.pickup");
+ method => "run_method",
+ api_name => "open-ils.circ.reservation.pickup"
+);
__PACKAGE__->register_method(
- method => "run_method",
- api_name => "open-ils.circ.reservation.return");
-
+ method => "run_method",
+ api_name => "open-ils.circ.reservation.return"
+);
__PACKAGE__->register_method(
- method => "run_method",
- api_name => "open-ils.circ.checkout.inspect",
- desc => q/
- Returns the circ matrix test result and, on success, the rule set and matrix test object
- /
+ method => "run_method",
+ api_name => "open-ils.circ.checkout.inspect",
+ desc => q/Returns the circ matrix test result and, on success, the rule set and matrix test object/
);
-
sub run_method {
my( $self, $conn, $auth, $args ) = @_;
translate_legacy_args($args);
@@ -197,7 +196,7 @@
if ($transit) { # yes! unwrap it.
my $reservation = $circulator->editor->retrieve_booking_reservation( $transit->reservation );
- my $res_type = $circulator->editor->retrieve_booking_resource_type( $reservation->target_resource_type );
+ my $res_type = $circulator->editor->retrieve_booking_resource_type( $reservation->target_resource_type );
if ($U->is_true($res_type->catalog_item)) { # is there a copy to be had here?
if (my $copy = $circulator->editor->search_asset_copy({ barcode => $bc, deleted => 'f' })->[0]) { # got a copy
@@ -338,7 +337,7 @@
# Log the events
my @e = @{$circulator->events};
push( @ee, $_->{textcode} ) for @e;
- $logger->info("circulator: bailing out with events: @ee");
+ $logger->info("circulator: bailing out with events: " . (join ", ", @ee));
$circulator->editor->rollback;
@@ -502,6 +501,7 @@
opac_renewal
phone_renewal
desk_renewal
+ sip_renewal
retarget
matrix_test_result
circ_matrix_matchpoint
@@ -568,7 +568,7 @@
# if this is a renewal, default to desk_renewal
$self->desk_renewal(1) unless
- $self->opac_renewal or $self->phone_renewal;
+ $self->opac_renewal or $self->phone_renewal or $self->sip_renewal;
$self->capture('') unless $self->capture;
@@ -2847,10 +2847,6 @@
my $self = shift;
my $copy = $self->copy;
- my $islost = 0;
- my $ismissing = 0;
- my $evt = undef;
-
my $status = $U->copy_status($copy->status)->id;
return undef
@@ -3133,7 +3129,7 @@
my $self = shift;
return unless $self->circ;
$U->create_events_for_hook('checkout', $self->circ, $self->circ_lib) if $self->is_checkout;
- $U->create_events_for_hook('checkin', $self->circ, $self->circ_lib) if $self->is_checkin;
+ $U->create_events_for_hook('checkin', $self->circ, $self->circ_lib) if $self->is_checkin;
$U->create_events_for_hook('renewal', $self->circ, $self->circ_lib) if $self->is_renewal;
}
Modified: trunk/Open-ILS/src/perlmods/OpenILS/SIP/Patron.pm
===================================================================
--- trunk/Open-ILS/src/perlmods/OpenILS/SIP/Patron.pm 2010-06-04 20:53:23 UTC (rev 16597)
+++ trunk/Open-ILS/src/perlmods/OpenILS/SIP/Patron.pm 2010-06-04 20:53:24 UTC (rev 16598)
@@ -78,9 +78,9 @@
return undef;
}
- $self->{user} = $user;
- $self->{id} = $patron_id;
- $self->{editor} = $e;
+ $self->{user} = $user;
+ $self->{id} = $patron_id;
+ $self->{editor} = $e;
syslog("LOG_DEBUG", "OILS: new OpenILS Patron(%s): found patron : barred=%s, card:active=%s",
$patron_id, $self->{user}->barred, $self->{user}->card->active );
@@ -159,14 +159,14 @@
# How much more detail do we need to check here?
sub charge_ok {
my $self = shift;
- my $u = $self->{user};
- return (($u->barred eq 'f') and ($u->card->active eq 't'));
+ my $u = $self->{user};
+ return (($u->barred eq 'f') and ($u->card->active eq 't'));
}
# How much more detail do we need to check here?
sub renew_ok {
my $self = shift;
- return $self->charge_ok;
+ return $self->charge_ok;
}
sub recall_ok {
@@ -176,13 +176,13 @@
sub hold_ok {
my $self = shift;
- return $self->charge_ok;
+ return $self->charge_ok;
}
# return true if the card provided is marked as lost
sub card_lost {
my $self = shift;
- return $self->{user}->card->active eq 'f';
+ return $self->{user}->card->active eq 'f';
}
sub recall_overdue {
@@ -511,6 +511,7 @@
sub block {
my ($self, $card_retained, $blocked_card_msg) = @_;
+ $blocked_card_msg ||= '';
my $e = $self->{editor};
my $u = $self->{user};
@@ -532,8 +533,8 @@
# retrieve the un-fleshed user object for update
$u = $e->retrieve_actor_user($u->id);
my $note = OpenILS::SIP::clean_text($u->alert_message) || "";
- $note = "CARD BLOCKED BY SELF-CHECK MACHINE\n$note"; # XXX Config option
-
+ $note = "<sip> CARD BLOCKED BY SELF-CHECK MACHINE. $blocked_card_msg</sip>\n$note"; # XXX Config option
+ $note =~ s/\s*$//; # kill trailng whitespace
$u->alert_message($note);
if( ! $e->update_actor_user($u) ) {
@@ -551,9 +552,43 @@
# Testing purposes only
sub enable {
- my $self = shift;
- # Un-mark card as inactive, grep out the patron alert
+ my ($self, $card_retained, $blocked_card_msg) = @_;
$self->{screen_msg} = "All privileges restored.";
+
+# Un-mark card as inactive, grep out the patron alert
+ my $u = $self->{user};
+ my $e = $self->{editor} = OpenILS::SIP->reset_editor();
+
+ syslog('LOG_INFO', "OILS: Unblocking user %s", $u->card->barcode );
+
+ return $self if $u->card->active eq 't';
+
+ $u->card->active('t');
+ if( ! $e->update_actor_card($u->card) ) {
+ syslog('LOG_ERR', "OILS: Unblock card update failed: %s", $e->event->{textcode});
+ $e->xact_rollback;
+ return $self;
+ }
+
+ # retrieve the un-fleshed user object for update
+ $u = $e->retrieve_actor_user($u->id);
+ my $note = OpenILS::SIP::clean_text($u->alert_message) || "";
+ $note =~ s#<sip>.*</sip>##;
+ $note =~ s/^\s*//; # kill leading whitespace
+ $note =~ s/\s*$//; # kill trailng whitespace
+ $u->alert_message($note);
+
+ if( ! $e->update_actor_user($u) ) {
+ syslog('LOG_ERR', "OILS: Unblock: patron alert update failed: %s", $e->event->{textcode});
+ $e->xact_rollback;
+ return $self;
+ }
+
+ # stay in synch
+ $self->{user}->alert_message( $note );
+
+ $e->commit; # commits and resets
+ $self->{editor} = OpenILS::SIP->reset_editor();
return $self;
}
Modified: trunk/Open-ILS/src/perlmods/OpenILS/SIP/Transaction/Renew.pm
===================================================================
--- trunk/Open-ILS/src/perlmods/OpenILS/SIP/Transaction/Renew.pm 2010-06-04 20:53:23 UTC (rev 16597)
+++ trunk/Open-ILS/src/perlmods/OpenILS/SIP/Transaction/Renew.pm 2010-06-04 20:53:24 UTC (rev 16598)
@@ -36,11 +36,10 @@
{ barcode => $self->item->id, patron_barcode => $self->patron->id });
if( my $code = $U->event_code($resp) ) {
- my $txt = $resp->{textcode};
- syslog('LOG_INFO', "OILS: Renewal failed with event $code : $txt");
+ syslog('LOG_INFO', "OILS: Renewal failed with event $code : " . $resp->{textcode});
$self->renewal_ok(0);
$self->ok(0);
- return 0;
+ return $self;
}
$self->item->{due_date} = $resp->{payload}->{circ}->due_date;
Modified: trunk/Open-ILS/src/perlmods/OpenILS/SIP.pm
===================================================================
--- trunk/Open-ILS/src/perlmods/OpenILS/SIP.pm 2010-06-04 20:53:23 UTC (rev 16597)
+++ trunk/Open-ILS/src/perlmods/OpenILS/SIP.pm 2010-06-04 20:53:24 UTC (rev 16598)
@@ -26,7 +26,7 @@
my $editor;
my $config;
-my $target_encoding;
+my $target_encoding; # FIXME: this is configured at the institution level.
use Digest::MD5 qw(md5_hex);
@@ -176,7 +176,7 @@
{
username => $username,
password => md5_hex($seed . md5_hex($password)),
- type => 'opac',
+ type => 'opac',
}
);
@@ -286,7 +286,7 @@
$xact->item($item);
if (!$patron) {
- $xact->screen_msg("Invalid Patron");
+ $xact->screen_msg("Invalid Patron Barcode '$patron_id'");
return $xact;
}
@@ -296,7 +296,7 @@
}
if( !$item ) {
- $xact->screen_msg("Invalid Item");
+ $xact->screen_msg("Invalid Item Barcode: '$item_id'");
return $xact;
}
@@ -316,13 +316,10 @@
$xact->desensitize(!$item->magnetic);
if( $xact->ok ) {
-
#editor()->commit;
syslog("LOG_DEBUG", "OILS: OpenILS::Checkout: " .
"patron %s checkout %s succeeded", $patron_id, $item_id);
-
} else {
-
#editor()->xact_rollback;
syslog("LOG_DEBUG", "OILS: OpenILS::Checkout: " .
"patron %s checkout %s FAILED, rolling back xact...", $patron_id, $item_id);
@@ -364,7 +361,6 @@
#editor()->xact_rollback;
syslog('LOG_WARNING', "OILS: Checkin failed");
}
- # END TRANSACTION
return $xact;
}
@@ -374,7 +370,7 @@
## We don't do anything with it.
sub end_patron_session {
my ($self, $patron_id) = @_;
- return (1, 'Thank you for using OpenILS!', '');
+ return (1, 'Thank you!', '');
}
More information about the open-ils-commits
mailing list