From c18603ae246551837c10d240b5ae1e40c816d978 Mon Sep 17 00:00:00 2001 From: Bill Erickson Date: Thu, 5 Apr 2012 17:30:54 -0400 Subject: [PATCH] kpac : hold placement; more auth refresh repairs Signed-off-by: Bill Erickson Signed-off-by: Mike Rylander --- .../lib/OpenILS/WWW/EGCatLoader/Account.pm | 2 + .../src/perlmods/lib/OpenILS/WWW/EGKPacLoader.pm | 58 +++++++++++++++------- Open-ILS/src/templates/kpac/getit_results.tt2 | 18 +++++-- Open-ILS/src/templates/kpac/parts/base.tt2 | 3 +- 4 files changed, 58 insertions(+), 23 deletions(-) diff --git a/Open-ILS/src/perlmods/lib/OpenILS/WWW/EGCatLoader/Account.pm b/Open-ILS/src/perlmods/lib/OpenILS/WWW/EGCatLoader/Account.pm index 10dd567092..c11efe1dbd 100644 --- a/Open-ILS/src/perlmods/lib/OpenILS/WWW/EGCatLoader/Account.pm +++ b/Open-ILS/src/perlmods/lib/OpenILS/WWW/EGCatLoader/Account.pm @@ -853,6 +853,8 @@ sub load_place_hold { } } + $self->apache->log->warn("$#parts : @t_holds"); + $self->attempt_hold_placement($usr, $pickup_lib, 'P', @p_holds) if @p_holds; $self->attempt_hold_placement($usr, $pickup_lib, 'T', @t_holds) if @t_holds; diff --git a/Open-ILS/src/perlmods/lib/OpenILS/WWW/EGKPacLoader.pm b/Open-ILS/src/perlmods/lib/OpenILS/WWW/EGKPacLoader.pm index 1aab231baa..5c80f92ea3 100644 --- a/Open-ILS/src/perlmods/lib/OpenILS/WWW/EGKPacLoader.pm +++ b/Open-ILS/src/perlmods/lib/OpenILS/WWW/EGKPacLoader.pm @@ -88,25 +88,52 @@ sub login_and_place_hold { my $password = $self->cgi->param('password'); my $pickup_lib = $self->cgi->param('pickup_lib'); + return Apache2::Const::HTTP_BAD_REQUEST + unless $pickup_lib =~ /^\d+$/; + + my $new_uri = $self->apache->unparsed_uri; + my $sep = ($new_uri =~ /\?/) ? '&' : '?'; + if (!$ctx->{user}) { # First, log the user in and return to + $self->apache->log->info("kpac: logging in $username"); + # TODO: let user know username/password is required.. return Apache2::Const::OK unless $username and $password; - my $new_uri = $self->apache->unparsed_uri; - my $sep = ($new_uri =~ /\?/) ? '&' : '?'; + $new_uri .= "${sep}pickup_lib=$pickup_lib&action=hold"; $self->cgi->param('redirect_to', $new_uri); return $self->load_login; - } - # TODO: place hold + } else { - my $hold_id = ''; -# (my $new_uri = $self->apache->unparsed_uri) =~ s/getit/getit_results/g; -# $new_uri .= ($new_uri =~ /\?/) ? "&hold=$hold_id" : "?hold=$hold_id"; -# return $self->generic_redirect($new_uri); + $self->apache->log->info("kpac: placing hold for $bre_id"); - return Apache2::Const::OK; + $new_uri =~ s/getit/getit_results/g; + $self->cgi->param('hold_target', $bre_id); + $self->cgi->param('hold_type', 'T'); + $self->cgi->param('part', ''); # needed even if unused + + my $stat = $self->load_place_hold; + + $self->apache->log->info("kpac: place hold returned $stat"); + + return $stat unless $stat == Apache2::Const::OK; + + my $hdata = $ctx->{hold_data}->[0]; # only 1 hold placed + if (my $hold_id = $hdata ? $hdata->{hold_success} : undef) { + + $self->apache->log->info("kpac: place hold succeeded"); + $new_uri .= "${sep}hold=$hold_id"; + + } else { + $self->apache->log->info("kpac: place hold failed : " . $ctx->{hold_failed_event}); + $new_uri .= "${sep}hold_failed=1"; + } + } + + $self->apache->log->info("kpac: place hold redirecting to: $new_uri"); + return $self->generic_redirect($new_uri); } sub save_item_to_bookbag { @@ -153,16 +180,13 @@ sub load_getit_results { if ($list) { if ($list eq 'anon') { - $ctx->{anon_list} = 1; + $ctx->{added_to_anon} = 1; } else { - $ctx->{list} = $e->retrieve_container_biblio_record_entry_bucket($list); + $ctx->{added_to_list} = $e->retrieve_container_biblio_record_entry_bucket($list); } - - } elsif ($hold_id) { - - # new hold means potential for replication lag - $e->xact_start; - # fetch the hold... + } else { + $e->xact_begin; + $ctx->{hold} = $e->retrieve_action_hold_request(8); $e->xact_rollback; } diff --git a/Open-ILS/src/templates/kpac/getit_results.tt2 b/Open-ILS/src/templates/kpac/getit_results.tt2 index ebd8de0fee..d1fba7f0fb 100644 --- a/Open-ILS/src/templates/kpac/getit_results.tt2 +++ b/Open-ILS/src/templates/kpac/getit_results.tt2 @@ -5,36 +5,44 @@ attrs = {marc_xml => ctx.marc_xml}; PROCESS get_marc_attrs args=attrs; ctx.page_title = l('Get it'); - kill_params = ['list', 'hold']; + kill_params = ['list', 'hold', 'hold_failed', 'pickup_lib']; title_html = attrs.title | html; %] -

You Got It!

- [% IF ctx.anon_list %] + [% IF ctx.added_to_anon %] +

[% l('You Saved It!') %]

[% |l(title_html) %] You successfully saved [_1].
To manage your lists, go to My Lists [% END %]

- [% ELSIF ctx.list %] + [% ELSIF ctx.added_to_list %] [% list_html = ctx.list.name | html %] +

[% l('You Saved It!') %]

[% |l(title_html, list_html) %] You successfully saved [_1] to [_2].
To manage your lists, go to My Lists [% END %]

- [% ELSE %] + [% ELSIF CGI.param('hold') %] [% lib_html = ctx.get_aou(ctx.hold.pickup_lib).name | html %] +

[% l('You Got It!') %]

[% |l(title_html, lib_html) %] Your request for [_1] was successful.
You will be able to pick up this material at [_2]. [% END %]

+ [% ELSE %] +

+ [% |l(title_html) %] + Unable to request [_1].
+ Please see a librarian. + [% END %] [% END %]

diff --git a/Open-ILS/src/templates/kpac/parts/base.tt2 b/Open-ILS/src/templates/kpac/parts/base.tt2 index ebfe0e586f..e80a4c18fc 100644 --- a/Open-ILS/src/templates/kpac/parts/base.tt2 +++ b/Open-ILS/src/templates/kpac/parts/base.tt2 @@ -4,7 +4,8 @@ [% IF ctx.authtime %] - + [% END %] [% l("Kid's Catalog - [_1]", ctx.page_title) %] -- 2.11.0