From 22cf523789cc97c733ef9a6caff418c79c73b6a2 Mon Sep 17 00:00:00 2001 From: Thomas Berezansky Date: Mon, 7 May 2012 11:40:41 -0400 Subject: [PATCH] Hold Editing: Retarget on some changes The main thing to cover is pickup library, but check a few other things too. Note that most of what is being checked likely doesn't change in any normal workflows or interfaces, but it looks like they could anyway later. Signed-off-by: Thomas Berezansky Signed-off-by: Mike Rylander --- .../lib/OpenILS/Application/Circ/Holds.pm | 15 +++++++++++++++ 1 file changed, 15 insertions(+) diff --git a/Open-ILS/src/perlmods/lib/OpenILS/Application/Circ/Holds.pm b/Open-ILS/src/perlmods/lib/OpenILS/Application/Circ/Holds.pm index 906ec5347f..097dc6970e 100644 --- a/Open-ILS/src/perlmods/lib/OpenILS/Application/Circ/Holds.pm +++ b/Open-ILS/src/perlmods/lib/OpenILS/Application/Circ/Holds.pm @@ -883,11 +883,23 @@ sub batch_update_hold { sub update_hold_impl { my($self, $e, $hold, $values) = @_; my $hold_status; + my $need_retarget = 0; unless($hold) { $hold = $e->retrieve_action_hold_request($values->{id}) or return $e->die_event; for my $k (keys %$values) { + # Outside of pickup_lib (covered by the first regex) I don't know when these would currently change. + # But hey, why not cover things that may happen later? + if ($k =~ '_(lib|ou)$' || $k eq 'target' || $k eq 'hold_type' || $k eq 'requestor' || $k eq 'selection_depth' || $k eq 'holdable_formats') { + if (defined $values->{$k} && defined $hold->$k() && $values->{$k} ne $hold->$k()) { + # Value changed? RETARGET! + $need_retarget = 1; + } elsif (defined $hold->$k() != defined $values->{$k}) { + # Value being set or cleared? RETARGET! + $need_retarget = 1; + } + } if (defined $values->{$k}) { $hold->$k($values->{$k}); } else { @@ -993,6 +1005,9 @@ sub update_hold_impl { # a change to mint-condition changes the set of potential copies, so retarget the hold; if($U->is_true($hold->mint_condition) and !$U->is_true($orig_hold->mint_condition)) { _reset_hold($self, $e->requestor, $hold) + } elsif($need_retarget && !defined $hold->capture_time()) { # If needed, retarget the hold due to changes + $U->storagereq( + 'open-ils.storage.action.hold_request.copy_targeter', undef, $hold->id ); } return $hold->id; -- 2.43.2