[open-ils-commits] [GIT] Evergreen ILS branch master updated. 96344f978048252424fa38fc80122bf398015da6
Evergreen Git
git at git.evergreen-ils.org
Fri Jun 24 11:06:22 EDT 2011
This is an automated email from the git hooks/post-receive script. It was
generated because a ref change was pushed to the repository containing
the project "Evergreen ILS".
The branch, master has been updated
via 96344f978048252424fa38fc80122bf398015da6 (commit)
via 42391f56d8d12535368d60a9bb486597b24b2084 (commit)
via aa861552a03d3b896e21723071549478454eb0ff (commit)
via bc3954d07ddac96ebb2e62d94530e51261575e0b (commit)
via 20502484e2e87cbc65476038ae4c3677bf7950f6 (commit)
via 5503e0ff2838bb9d392b95bd1f9341127e20e960 (commit)
via 6c3b571395aff3551d9fafff7e8a6654893f0996 (commit)
via 95206809441fee6bc01d166539a4c42e0ea2f40b (commit)
from 064372f160214538c92fe0bb67ee119369521d21 (commit)
Those revisions listed above that are new to this repository have
not appeared on any other notification email; so we list those
revisions in full, below.
- Log -----------------------------------------------------------------
commit 96344f978048252424fa38fc80122bf398015da6
Author: Jason Etheridge <jason at esilibrary.com>
Date: Fri Jun 24 11:13:41 2011 -0400
upgrade script for A/T event def: Hold Cancelled (No Target) Email Notification
Signed-off-by: Jason Etheridge <jason at esilibrary.com>
diff --git a/Open-ILS/src/sql/Pg/002.schema.config.sql b/Open-ILS/src/sql/Pg/002.schema.config.sql
index aebecc3..d1a1417 100644
--- a/Open-ILS/src/sql/Pg/002.schema.config.sql
+++ b/Open-ILS/src/sql/Pg/002.schema.config.sql
@@ -86,7 +86,7 @@ CREATE TRIGGER no_overlapping_deps
BEFORE INSERT OR UPDATE ON config.db_patch_dependencies
FOR EACH ROW EXECUTE PROCEDURE evergreen.array_overlap_check ('deprecates');
-INSERT INTO config.upgrade_log (version, applied_to) VALUES ('0564', :eg_version); -- berick via phasefx
+INSERT INTO config.upgrade_log (version, applied_to) VALUES ('0565', :eg_version); -- berick via phasefx
CREATE TABLE config.bib_source (
id SERIAL PRIMARY KEY,
diff --git a/Open-ILS/src/sql/Pg/upgrade/0565.schema.action-trigger.event_definition.hold-cancel-no-target-notification.sql b/Open-ILS/src/sql/Pg/upgrade/0565.schema.action-trigger.event_definition.hold-cancel-no-target-notification.sql
new file mode 100644
index 0000000..63a99c5
--- /dev/null
+++ b/Open-ILS/src/sql/Pg/upgrade/0565.schema.action-trigger.event_definition.hold-cancel-no-target-notification.sql
@@ -0,0 +1,39 @@
+-- Evergreen DB patch 0565.schema.action-trigger.event_definition.hold-cancel-no-target-notification.sql
+--
+-- New action trigger event definition: Hold Cancelled (No Target) Email Notification
+--
+BEGIN;
+
+-- check whether patch can be applied
+SELECT evergreen.upgrade_deps_block_check('0565', :eg_version);
+
+INSERT INTO action_trigger.event_definition (id, active, owner, name, hook, validator, reactor, delay, delay_field, group_field, template)
+ VALUES (38, FALSE, 1,
+ 'Hold Cancelled (No Target) Email Notification',
+ 'hold_request.cancel.expire_no_target',
+ 'HoldIsCancelled', 'SendEmail', '30 minutes', 'cancel_time', 'usr',
+$$
+[%- USE date -%]
+[%- user = target.0.usr -%]
+To: [%- params.recipient_email || user.email %]
+From: [%- params.sender_email || default_sender %]
+Subject: Hold Request Cancelled
+
+Dear [% user.family_name %], [% user.first_given_name %]
+The following holds were cancelled because no items were found to fullfil the hold.
+
+[% FOR hold IN target %]
+ Title: [% hold.bib_rec.bib_record.simple_record.title %]
+ Author: [% hold.bib_rec.bib_record.simple_record.author %]
+ Library: [% hold.pickup_lib.name %]
+ Request Date: [% date.format(helpers.format_date(hold.rrequest_time), '%Y-%m-%d') %]
+[% END %]
+
+$$);
+
+INSERT INTO action_trigger.environment (event_def, path) VALUES
+ (38, 'usr'),
+ (38, 'pickup_lib'),
+ (38, 'bib_rec.bib_record.simple_record');
+
+COMMIT;
commit 42391f56d8d12535368d60a9bb486597b24b2084
Author: Jason Etheridge <jason at esilibrary.com>
Date: Fri Jun 24 11:10:40 2011 -0400
cat.volume.delete_on_empty org setting. break up and wrap the upgrade script
Signed-off-by: Jason Etheridge <jason at esilibrary.com>
diff --git a/Open-ILS/src/sql/Pg/002.schema.config.sql b/Open-ILS/src/sql/Pg/002.schema.config.sql
index 5ce512c..aebecc3 100644
--- a/Open-ILS/src/sql/Pg/002.schema.config.sql
+++ b/Open-ILS/src/sql/Pg/002.schema.config.sql
@@ -86,7 +86,7 @@ CREATE TRIGGER no_overlapping_deps
BEFORE INSERT OR UPDATE ON config.db_patch_dependencies
FOR EACH ROW EXECUTE PROCEDURE evergreen.array_overlap_check ('deprecates');
-INSERT INTO config.upgrade_log (version, applied_to) VALUES ('0563', :eg_version); -- berick via miker
+INSERT INTO config.upgrade_log (version, applied_to) VALUES ('0564', :eg_version); -- berick via phasefx
CREATE TABLE config.bib_source (
id SERIAL PRIMARY KEY,
diff --git a/Open-ILS/src/sql/Pg/upgrade/0564.data.org-setting-cat.volume.delete_on_empty.sql b/Open-ILS/src/sql/Pg/upgrade/0564.data.org-setting-cat.volume.delete_on_empty.sql
new file mode 100644
index 0000000..d5c5213
--- /dev/null
+++ b/Open-ILS/src/sql/Pg/upgrade/0564.data.org-setting-cat.volume.delete_on_empty.sql
@@ -0,0 +1,19 @@
+-- Evergreen DB patch 0564.data.delete_empty_volume.sql
+--
+-- New org setting cat.volume.delete_on_empty
+--
+BEGIN;
+
+-- check whether patch can be applied
+SELECT evergreen.upgrade_deps_block_check('0564', :eg_version);
+
+INSERT INTO config.org_unit_setting_type ( name, label, description, datatype )
+ VALUES (
+ 'cat.volume.delete_on_empty',
+ oils_i18n_gettext('cat.volume.delete_on_empty', 'Cat: Delete volume with last copy', 'coust', 'label'),
+ oils_i18n_gettext('cat.volume.delete_on_empty', 'Automatically delete a volume when the last linked copy is deleted', 'coust', 'description'),
+ 'bool'
+ );
+
+
+COMMIT;
diff --git a/Open-ILS/src/sql/Pg/upgrade/XXXX.data.delete_empty_volume.sql b/Open-ILS/src/sql/Pg/upgrade/XXXX.data.delete_empty_volume.sql
deleted file mode 100644
index 6c0b6f8..0000000
--- a/Open-ILS/src/sql/Pg/upgrade/XXXX.data.delete_empty_volume.sql
+++ /dev/null
@@ -1,48 +0,0 @@
--- Evergreen DB patch XXXX.data.delete_empty_volume.sql
---
--- New org setting cat.volume.delete_on_empty
---
-BEGIN;
-
--- check whether patch can be applied
-SELECT evergreen.upgrade_deps_block_check('XXXX', :eg_version);
-
-INSERT INTO config.org_unit_setting_type ( name, label, description, datatype )
- VALUES (
- 'cat.volume.delete_on_empty',
- oils_i18n_gettext('cat.volume.delete_on_empty', 'Cat: Delete volume with last copy', 'coust', 'label'),
- oils_i18n_gettext('cat.volume.delete_on_empty', 'Automatically delete a volume when the last linked copy is deleted', 'coust', 'description'),
- 'bool'
- );
-
-INSERT INTO action_trigger.event_definition (id, active, owner, name, hook, validator, reactor, delay, delay_field, group_field, template)
- VALUES (38, FALSE, 1,
- 'Hold Cancelled (No Target) Email Notification',
- 'hold_request.cancel.expire_no_target',
- 'HoldIsCancelled', 'SendEmail', '30 minutes', 'cancel_time', 'usr',
-$$
-[%- USE date -%]
-[%- user = target.0.usr -%]
-To: [%- params.recipient_email || user.email %]
-From: [%- params.sender_email || default_sender %]
-Subject: Hold Request Cancelled
-
-Dear [% user.family_name %], [% user.first_given_name %]
-The following holds were cancelled because no items were found to fullfil the hold.
-
-[% FOR hold IN target %]
- Title: [% hold.bib_rec.bib_record.simple_record.title %]
- Author: [% hold.bib_rec.bib_record.simple_record.author %]
- Library: [% hold.pickup_lib.name %]
- Request Date: [% date.format(helpers.format_date(hold.rrequest_time), '%Y-%m-%d') %]
-[% END %]
-
-$$);
-
-INSERT INTO action_trigger.environment (event_def, path) VALUES
- (38, 'usr'),
- (38, 'pickup_lib'),
- (38, 'bib_rec.bib_record.simple_record');
-
-
-COMMIT;
commit aa861552a03d3b896e21723071549478454eb0ff
Author: Bill Erickson <berick at esilibrary.com>
Date: Mon Jun 6 17:07:27 2011 -0400
Sample hold cancelled with no target notice
Signed-off-by: Bill Erickson <berick at esilibrary.com>
Signed-off-by: Jason Etheridge <jason at esilibrary.com>
diff --git a/Open-ILS/src/sql/Pg/950.data.seed-values.sql b/Open-ILS/src/sql/Pg/950.data.seed-values.sql
index 191da0f..dc036a9 100644
--- a/Open-ILS/src/sql/Pg/950.data.seed-values.sql
+++ b/Open-ILS/src/sql/Pg/950.data.seed-values.sql
@@ -8756,3 +8756,35 @@ INSERT INTO config.org_unit_setting_type
'bool'
);
+-- Event def for email notice for hold cancelled due to lack of target -----
+
+INSERT INTO action_trigger.event_definition (id, active, owner, name, hook, validator, reactor, delay, delay_field, group_field, template)
+ VALUES (38, FALSE, 1,
+ 'Hold Cancelled (No Target) Email Notification',
+ 'hold_request.cancel.expire_no_target',
+ 'HoldIsCancelled', 'SendEmail', '30 minutes', 'cancel_time', 'usr',
+$$
+[%- USE date -%]
+[%- user = target.0.usr -%]
+To: [%- params.recipient_email || user.email %]
+From: [%- params.sender_email || default_sender %]
+Subject: Hold Request Cancelled
+
+Dear [% user.family_name %], [% user.first_given_name %]
+The following holds were cancelled because no items were found to fullfil the hold.
+
+[% FOR hold IN target %]
+ Title: [% hold.bib_rec.bib_record.simple_record.title %]
+ Author: [% hold.bib_rec.bib_record.simple_record.author %]
+ Library: [% hold.pickup_lib.name %]
+ Request Date: [% date.format(helpers.format_date(hold.rrequest_time), '%Y-%m-%d') %]
+[% END %]
+
+$$);
+
+INSERT INTO action_trigger.environment (event_def, path) VALUES
+ (38, 'usr'),
+ (38, 'pickup_lib'),
+ (38, 'bib_rec.bib_record.simple_record');
+
+
diff --git a/Open-ILS/src/sql/Pg/upgrade/XXXX.data.delete_empty_volume.sql b/Open-ILS/src/sql/Pg/upgrade/XXXX.data.delete_empty_volume.sql
index d4a529f..6c0b6f8 100644
--- a/Open-ILS/src/sql/Pg/upgrade/XXXX.data.delete_empty_volume.sql
+++ b/Open-ILS/src/sql/Pg/upgrade/XXXX.data.delete_empty_volume.sql
@@ -15,4 +15,34 @@ INSERT INTO config.org_unit_setting_type ( name, label, description, datatype )
'bool'
);
+INSERT INTO action_trigger.event_definition (id, active, owner, name, hook, validator, reactor, delay, delay_field, group_field, template)
+ VALUES (38, FALSE, 1,
+ 'Hold Cancelled (No Target) Email Notification',
+ 'hold_request.cancel.expire_no_target',
+ 'HoldIsCancelled', 'SendEmail', '30 minutes', 'cancel_time', 'usr',
+$$
+[%- USE date -%]
+[%- user = target.0.usr -%]
+To: [%- params.recipient_email || user.email %]
+From: [%- params.sender_email || default_sender %]
+Subject: Hold Request Cancelled
+
+Dear [% user.family_name %], [% user.first_given_name %]
+The following holds were cancelled because no items were found to fullfil the hold.
+
+[% FOR hold IN target %]
+ Title: [% hold.bib_rec.bib_record.simple_record.title %]
+ Author: [% hold.bib_rec.bib_record.simple_record.author %]
+ Library: [% hold.pickup_lib.name %]
+ Request Date: [% date.format(helpers.format_date(hold.rrequest_time), '%Y-%m-%d') %]
+[% END %]
+
+$$);
+
+INSERT INTO action_trigger.environment (event_def, path) VALUES
+ (38, 'usr'),
+ (38, 'pickup_lib'),
+ (38, 'bib_rec.bib_record.simple_record');
+
+
COMMIT;
commit bc3954d07ddac96ebb2e62d94530e51261575e0b
Author: Bill Erickson <berick at esilibrary.com>
Date: Mon Jun 6 16:35:11 2011 -0400
Cancel bib holds with bib is deleted
And notify user via A/T
Signed-off-by: Bill Erickson <berick at esilibrary.com>
Signed-off-by: Jason Etheridge <jason at esilibrary.com>
diff --git a/Open-ILS/src/perlmods/lib/OpenILS/Application/Cat/BibCommon.pm b/Open-ILS/src/perlmods/lib/OpenILS/Application/Cat/BibCommon.pm
index 4d928a8..6a776d8 100644
--- a/Open-ILS/src/perlmods/lib/OpenILS/Application/Cat/BibCommon.pm
+++ b/Open-ILS/src/perlmods/lib/OpenILS/Application/Cat/BibCommon.pm
@@ -340,6 +340,32 @@ sub delete_rec {
$editor->update_biblio_record_entry($rec) or return $editor->event;
+ my $holds = $editor->search_action_hold_request({
+ target => $rec->id,
+ hold_type => 'T',
+ cancel_time => undef,
+ fulfillment_time => undef
+ });
+
+ for my $hold (@$holds) {
+
+ $hold->cancel_time('now');
+ $hold->cancel_cause(1); # un-targeted expiration.
+ $editor->update_action_hold_request($hold) or return $editor->die_event;
+
+ my $maps = $editor->search_action_hold_copy_map({hold => $hold->id});
+ for(@$maps) {
+ $editor->delete_action_hold_copy_map($_)
+ or return $editor->die_event;
+ }
+
+ my $at_ses = OpenSRF::AppSession->create('open-ils.trigger');
+ $at_ses->request(
+ 'open-ils.trigger.event.autocreate',
+ 'hold_request.cancel.expire_no_target',
+ $hold, $hold->pickup_lib);
+ }
+
return undef;
}
commit 20502484e2e87cbc65476038ae4c3677bf7950f6
Author: Bill Erickson <berick at esilibrary.com>
Date: Mon Jun 6 14:26:42 2011 -0400
Cancel volume/copy holds on delete
Cancel all holds that directly target a copy or volume when the
copy/volume is being deleted.
Sends async message to A/T for each hold to create and run the
necessary events (e.g. send cancellation notices).
Signed-off-by: Bill Erickson <berick at esilibrary.com>
Signed-off-by: Jason Etheridge <jason at esilibrary.com>
diff --git a/Open-ILS/src/perlmods/lib/OpenILS/Application/Cat/AssetCommon.pm b/Open-ILS/src/perlmods/lib/OpenILS/Application/Cat/AssetCommon.pm
index 5ac2a1d..11ecdfc 100644
--- a/Open-ILS/src/perlmods/lib/OpenILS/Application/Cat/AssetCommon.pm
+++ b/Open-ILS/src/perlmods/lib/OpenILS/Application/Cat/AssetCommon.pm
@@ -347,6 +347,9 @@ sub delete_copy {
or return $editor->event;
}
+ my $evt = $class->cancel_copy_holds($editor, $copy);
+ return $evt if $evt;
+
$class->check_hold_retarget($editor, $copy, undef, $retarget_holds);
return undef if $skip_empty_cleanup;
@@ -355,6 +358,62 @@ sub delete_copy {
}
+# deletes all holds that specifically target the deleted copy
+sub cancel_copy_holds {
+ my($class, $editor, $copy) = @_;
+
+ my $holds = $editor->search_action_hold_request({
+ target => $copy->id,
+ hold_type => [qw/C R F/],
+ cancel_time => undef,
+ fulfillment_time => undef
+ });
+
+ return $class->cancel_hold_list($editor, $holds);
+}
+
+# deletes all holds that specifically target the deleted volume
+sub cancel_volume_holds {
+ my($class, $editor, $volume) = @_;
+
+ my $holds = $editor->search_action_hold_request({
+ target => $volume->id,
+ hold_type => 'V',
+ cancel_time => undef,
+ fulfillment_time => undef
+ });
+
+ return $class->cancel_hold_list($editor, $holds);
+}
+
+sub cancel_hold_list {
+ my($class, $editor, $holds) = @_;
+
+ for my $hold (@$holds) {
+
+ $hold->cancel_time('now');
+ $hold->cancel_cause(1); # un-targeted expiration. Do we need an alternate "target deleted" cause?
+ $editor->update_action_hold_request($hold) or return $editor->die_event;
+
+ # delete the copy maps.
+ my $maps = $editor->search_action_hold_copy_map({hold => $hold->id});
+ for(@$maps) {
+ $editor->delete_action_hold_copy_map($_)
+ or return $editor->die_event;
+ }
+
+ # tell A/T the hold was cancelled. Don't wait for a response..
+ my $at_ses = OpenSRF::AppSession->create('open-ils.trigger');
+ $at_ses->request(
+ 'open-ils.trigger.event.autocreate',
+ 'hold_request.cancel.expire_no_target',
+ $hold, $hold->pickup_lib);
+ }
+
+ return undef;
+}
+
+
sub create_volume {
my($class, $override, $editor, $vol) = @_;
@@ -548,6 +607,9 @@ sub delete_volume {
$vol->editor($editor->requestor->id);
$editor->update_asset_call_number($vol) or return $editor->die_event;
+ $evt = $class->cancel_volume_holds($editor, $vol);
+ return $evt if $evt;
+
# handle the case where this is the last volume on the record
return $class->remove_empty_objects($editor, $override, $vol);
}
commit 5503e0ff2838bb9d392b95bd1f9341127e20e960
Author: Bill Erickson <berick at esilibrary.com>
Date: Fri Jun 3 13:24:16 2011 -0400
unwrapped upgrade script for cat.volume.delete_on_empty
Signed-off-by: Bill Erickson <berick at esilibrary.com>
Signed-off-by: Jason Etheridge <jason at esilibrary.com>
diff --git a/Open-ILS/src/sql/Pg/upgrade/XXXX.data.delete_empty_volume.sql b/Open-ILS/src/sql/Pg/upgrade/XXXX.data.delete_empty_volume.sql
new file mode 100644
index 0000000..d4a529f
--- /dev/null
+++ b/Open-ILS/src/sql/Pg/upgrade/XXXX.data.delete_empty_volume.sql
@@ -0,0 +1,18 @@
+-- Evergreen DB patch XXXX.data.delete_empty_volume.sql
+--
+-- New org setting cat.volume.delete_on_empty
+--
+BEGIN;
+
+-- check whether patch can be applied
+SELECT evergreen.upgrade_deps_block_check('XXXX', :eg_version);
+
+INSERT INTO config.org_unit_setting_type ( name, label, description, datatype )
+ VALUES (
+ 'cat.volume.delete_on_empty',
+ oils_i18n_gettext('cat.volume.delete_on_empty', 'Cat: Delete volume with last copy', 'coust', 'label'),
+ oils_i18n_gettext('cat.volume.delete_on_empty', 'Automatically delete a volume when the last linked copy is deleted', 'coust', 'description'),
+ 'bool'
+ );
+
+COMMIT;
commit 6c3b571395aff3551d9fafff7e8a6654893f0996
Author: Bill Erickson <berick at esilibrary.com>
Date: Fri Jun 3 13:21:37 2011 -0400
Delete volume on last copy setting
When the last copy for a volume is deleted, go ahead and delete the
volume when this new setting is activated.
Signed-off-by: Bill Erickson <berick at esilibrary.com>
Signed-off-by: Jason Etheridge <jason at esilibrary.com>
diff --git a/Open-ILS/src/perlmods/lib/OpenILS/Application/Cat/AssetCommon.pm b/Open-ILS/src/perlmods/lib/OpenILS/Application/Cat/AssetCommon.pm
index 555e4b7..5ac2a1d 100644
--- a/Open-ILS/src/perlmods/lib/OpenILS/Application/Cat/AssetCommon.pm
+++ b/Open-ILS/src/perlmods/lib/OpenILS/Application/Cat/AssetCommon.pm
@@ -200,7 +200,10 @@ sub update_copy {
$logger->info("vol-update: updating copy ".$copy->id);
my $orig_copy = $editor->retrieve_asset_copy($copy->id);
- my $orig_vol = $editor->retrieve_asset_call_number($copy->call_number);
+
+ # Call-number may have changed, find the original
+ my $orig_vol_id = $editor->json_query({select => {acp => ['call_number']}, from => 'acp', where => {id => $copy->id}});
+ my $orig_vol = $editor->retrieve_asset_call_number($orig_vol_id->[0]->{call_number});
$copy->editor($editor->requestor->id);
$copy->edit_date('now');
@@ -493,7 +496,27 @@ sub remove_empty_objects {
my $evt = OpenILS::Application::Cat::BibCommon->delete_rec($editor, $vol->record);
return $evt if $evt;
}
- }
+
+ } else {
+
+ # this may be the last copy attached to the volume.
+
+ if($U->ou_ancestor_setting_value(
+ $editor->requestor->ws_ou, 'cat.volume.delete_on_empty', $editor)) {
+
+ # if this volume is "empty" and not mid-delete, delete it.
+ unless($U->is_true($vol->deleted) || $vol->isdeleted) {
+
+ my $copies = $editor->search_asset_copy(
+ [{call_number => $vol->id, deleted => 'f'}, {limit => 1}], {idlist => 1});
+
+ if(!@$copies) {
+ my $evt = $class->delete_volume($editor, $vol, $override, 0, 1);
+ return $evt if $evt;
+ }
+ }
+ }
+ }
return undef;
}
diff --git a/Open-ILS/src/sql/Pg/950.data.seed-values.sql b/Open-ILS/src/sql/Pg/950.data.seed-values.sql
index a134560..191da0f 100644
--- a/Open-ILS/src/sql/Pg/950.data.seed-values.sql
+++ b/Open-ILS/src/sql/Pg/950.data.seed-values.sql
@@ -8748,3 +8748,11 @@ INSERT INTO config.org_unit_setting_type ( name, label, description, datatype )
'interval'
);
+INSERT INTO config.org_unit_setting_type
+( name, label, description, datatype ) VALUES
+( 'cat.volume.delete_on_empty',
+ oils_i18n_gettext('cat.volume.delete_on_empty', 'Cat: Delete volume with last copy', 'coust', 'label'),
+ oils_i18n_gettext('cat.volume.delete_on_empty', 'Automatically delete a volume when the last linked copy is deleted', 'coust', 'description'),
+ 'bool'
+);
+
diff --git a/Open-ILS/xul/staff_client/server/cat/copy_browser.js b/Open-ILS/xul/staff_client/server/cat/copy_browser.js
index 7a734fc..9122655 100644
--- a/Open-ILS/xul/staff_client/server/cat/copy_browser.js
+++ b/Open-ILS/xul/staff_client/server/cat/copy_browser.js
@@ -683,27 +683,42 @@ cat.copy_browser.prototype = {
document.getElementById('commonStrings').getString('common.confirm')
);
- if (r == 0) {
+ if (r == 0) { // delete vols
for (var i = 0; i < list.length; i++) {
list[i].isdeleted('1');
}
- var robj = obj.network.simple_request(
- 'FM_ACN_TREE_UPDATE',
- [ ses(), list, true ],
- null,
- {
- 'title' : document.getElementById('catStrings').getString('staff.cat.copy_browser.delete_volume.override'),
- 'overridable_events' : [
- ]
- }
- );
- if (robj == null) throw(robj);
- if (typeof robj.ilsevent != 'undefined') {
- if (robj.ilsevent == 1206 /* VOLUME_NOT_EMPTY */) {
- alert(document.getElementById('catStrings').getString('staff.cat.copy_browser.delete_volume.copies_remain'));
- return;
+ var params = {};
+ loop: while(true) {
+ var robj = obj.network.simple_request(
+ 'FM_ACN_TREE_UPDATE',
+ [ ses(), list, true, params ],
+ null,
+ {
+ 'title' : document.getElementById('catStrings').getString('staff.cat.copy_browser.delete_volume.override'),
+ 'overridable_events' : [
+ ]
+ }
+ );
+ if (robj == null) throw(robj);
+ if (typeof robj.ilsevent != 'undefined') {
+ if (robj.ilsevent == 1206 /* VOLUME_NOT_EMPTY */) {
+ var r2 = obj.error.yns_alert(
+ document.getElementById('catStrings').getString('staff.cat.copy_browser.delete_volume.copies_remain'),
+ document.getElementById('catStrings').getString('staff.cat.copy_browser.delete_volume.title'),
+ document.getElementById('catStrings').getString('staff.cat.copy_browser.delete_volume.copies_remain.confirm'),
+ document.getElementById('catStrings').getString('staff.cat.copy_browser.delete_volume.copies_remain.cancel'),
+ null,
+ document.getElementById('commonStrings').getString('common.confirm')
+ );
+ if (r2 == 0) { // delete vols and copies
+ params.force_delete_copies = true;
+ continue loop;
+ }
+ } else {
+ if (robj.ilsevent != 0) throw(robj);
+ }
}
- if (robj.ilsevent != 0) throw(robj);
+ break loop;
}
obj.refresh_list();
}
diff --git a/Open-ILS/xul/staff_client/server/circ/copy_status.js b/Open-ILS/xul/staff_client/server/circ/copy_status.js
index 9ff0201..f2816c1 100644
--- a/Open-ILS/xul/staff_client/server/circ/copy_status.js
+++ b/Open-ILS/xul/staff_client/server/circ/copy_status.js
@@ -802,23 +802,38 @@ circ.copy_status.prototype = {
for (var i = 0; i < list.length; i++) {
list[i].isdeleted('1');
}
- var robj = obj.network.simple_request(
- 'FM_ACN_TREE_UPDATE',
- [ ses(), list, true ],
- null,
- {
- 'title' : document.getElementById('circStrings').getString('staff.circ.copy_status.delete_volumes.override'),
- 'overridable_events' : [
- ]
- }
- );
- if (robj == null) throw(robj);
- if (typeof robj.ilsevent != 'undefined') {
- if (robj.ilsevent == 1206 /* VOLUME_NOT_EMPTY */) {
- alert(document.getElementById('circStrings').getString('staff.circ.copy_status.delete_volumes.delete_copies'));
- return;
+ var params = {};
+ loop: while(true) {
+ var robj = obj.network.simple_request(
+ 'FM_ACN_TREE_UPDATE',
+ [ ses(), list, true, params ],
+ null,
+ {
+ 'title' : document.getElementById('circStrings').getString('staff.circ.copy_status.delete_volumes.override'),
+ 'overridable_events' : [
+ ]
+ }
+ );
+ if (robj == null) throw(robj);
+ if (typeof robj.ilsevent != 'undefined') {
+ if (robj.ilsevent == 1206 /* VOLUME_NOT_EMPTY */) {
+ var r2 = obj.error.yns_alert(
+ document.getElementById('circStrings').getString('staff.circ.copy_status.delete_volumes.delete_copies'),
+ document.getElementById('circStrings').getString('staff.circ.copy_status.delete_volumes.title'),
+ document.getElementById('circStrings').getString('staff.circ.copy_status.delete_volumes.delete_copies.confirm'),
+ document.getElementById('circStrings').getString('staff.circ.copy_status.delete_volumes.delete_copies.cancel'),
+ null,
+ document.getElementById('commonStrings').getString('common.confirm')
+ );
+ if (r2 == 0) { // delete vols and copies
+ params.force_delete_copies = true;
+ continue loop;
+ }
+ } else {
+ if (robj.ilsevent != 0) { throw(robj); }
+ }
}
- if (robj.ilsevent != 0) { throw(robj); }
+ break loop;
}
alert(document.getElementById('circStrings').getString('staff.circ.copy_status.delete_volumes.success'));
}
diff --git a/Open-ILS/xul/staff_client/server/locale/en-US/cat.properties b/Open-ILS/xul/staff_client/server/locale/en-US/cat.properties
index 0287758..f75c4e9 100644
--- a/Open-ILS/xul/staff_client/server/locale/en-US/cat.properties
+++ b/Open-ILS/xul/staff_client/server/locale/en-US/cat.properties
@@ -56,7 +56,9 @@ staff.cat.copy_browser.delete_volume.title=Delete Volumes?
staff.cat.copy_browser.delete_volume.delete=Delete
staff.cat.copy_browser.delete_volume.cancel=Cancel
staff.cat.copy_browser.delete_volume.override=Override Delete Failure?
-staff.cat.copy_browser.delete_volume.copies_remain=You must delete all the copies on the volume before you may delete the volume itself.
+staff.cat.copy_browser.delete_volume.copies_remain=You must delete all the items on the volume before you may delete the volume itself.
+staff.cat.copy_browser.delete_volume.copies_remain.confirm=Delete Volume and Items
+staff.cat.copy_browser.delete_volume.copies_remain.cancel=Cancel Delete
staff.cat.copy_browser.delete_volume.exception=copy browser -> delete volumes
staff.cat.copy_browser.mark_library.alert=Library + Record marked as Volume Transfer Destination
staff.cat.copy_browser.mark_library.prompt=Choose just one Library to mark as Volume Transfer Destination
diff --git a/Open-ILS/xul/staff_client/server/locale/en-US/circ.properties b/Open-ILS/xul/staff_client/server/locale/en-US/circ.properties
index 66ed6a3..15f4d37 100644
--- a/Open-ILS/xul/staff_client/server/locale/en-US/circ.properties
+++ b/Open-ILS/xul/staff_client/server/locale/en-US/circ.properties
@@ -134,7 +134,9 @@ staff.circ.copy_status.delete_volumes.title=Delete Volumes?
staff.circ.copy_status.delete_volumes.delete=Delete
staff.circ.copy_status.delete_volumes.cancel=Cancel
staff.circ.copy_status.delete_volumes.override=Override Delete Failure?
-staff.circ.copy_status.delete_volumes.delete_copies=You must delete all the copies on the volume before you may delete the volume itself.
+staff.circ.copy_status.delete_volumes.delete_copies=You must delete all the items on the volume before you may delete the volume itself.
+staff.circ.copy_status.delete_volumes.delete_copies.confirm=Delete Volume and Items
+staff.circ.copy_status.delete_volumes.delete_copies.cancel=Cancel Delete
staff.circ.copy_status.delete_volumes.success=Volumes deleted.
staff.circ.copy_status.mark_volume.status=Volume marked as Item Transfer Destination
staff.circ.copy_status.mark_volume.prompt=Choose just one Volume to mark as Item Transfer Destination
commit 95206809441fee6bc01d166539a4c42e0ea2f40b
Author: Bill Erickson <berick at esilibrary.com>
Date: Thu Jun 2 14:44:28 2011 -0400
Option to force-delete copies during volume delete
Added a "force_delete_copies" option to
open-ils.cat.asset.volume.fleshed.batch.update* which forces deletion of
all copies attached to a volume if the volume is being deleted. There
are still scenarios that will result in copies not being deleted
(e.g. copy is checked out), in which case the override option will
behave here the same way it behaves in
open-ils.cat.asset.copy.fleshed.batch.update*
Signed-off-by: Bill Erickson <berick at esilibrary.com>
Signed-off-by: Jason Etheridge <jason at esilibrary.com>
diff --git a/Open-ILS/src/perlmods/lib/OpenILS/Application/Cat.pm b/Open-ILS/src/perlmods/lib/OpenILS/Application/Cat.pm
index 974390e..8e311f6 100644
--- a/Open-ILS/src/perlmods/lib/OpenILS/Application/Cat.pm
+++ b/Open-ILS/src/perlmods/lib/OpenILS/Application/Cat.pm
@@ -26,6 +26,7 @@ use OpenSRF::AppSession;
my $U = "OpenILS::Application::AppUtils";
my $conf;
my %marctemplates;
+my $assetcom = 'OpenILS::Application::Cat::AssetCommon';
__PACKAGE__->register_method(
method => "retrieve_marc_template",
@@ -868,21 +869,20 @@ sub fleshed_volume_update {
if( $vol->isdeleted ) {
$logger->info("vol-update: deleting volume");
- return $editor->event unless
+ return $editor->die_event unless
$editor->allowed('UPDATE_VOLUME', $vol->owning_lib);
- my $cs = $editor->search_asset_copy(
- { call_number => $vol->id, deleted => 'f' } );
- return OpenILS::Event->new(
- 'VOLUME_NOT_EMPTY', payload => $vol->id ) if @$cs;
- $vol->deleted('t');
- return $editor->event unless
+ if(my $evt = $assetcom->delete_volume($editor, $vol, $override, $$options{force_delete_copies})) {
+ $editor->rollback;
+ return $evt;
+ }
+
+ return $editor->die_event unless
$editor->update_asset_call_number($vol);
-
} elsif( $vol->isnew ) {
$logger->info("vol-update: creating volume");
- $evt = OpenILS::Application::Cat::AssetCommon->create_volume( $override, $editor, $vol );
+ $evt = $assetcom->create_volume( $override, $editor, $vol );
return $evt if $evt;
} elsif( $vol->ischanged ) {
@@ -895,7 +895,7 @@ sub fleshed_volume_update {
# now update any attached copies
if( $copies and @$copies and !$vol->isdeleted ) {
$_->call_number($vol->id) for @$copies;
- $evt = OpenILS::Application::Cat::AssetCommon->update_fleshed_copies(
+ $evt = $assetcom->update_fleshed_copies(
$editor, $override, $vol, $copies, $delete_stats, $retarget_holds, undef);
return $evt if $evt;
}
diff --git a/Open-ILS/src/perlmods/lib/OpenILS/Application/Cat/AssetCommon.pm b/Open-ILS/src/perlmods/lib/OpenILS/Application/Cat/AssetCommon.pm
index c24a9f3..555e4b7 100644
--- a/Open-ILS/src/perlmods/lib/OpenILS/Application/Cat/AssetCommon.pm
+++ b/Open-ILS/src/perlmods/lib/OpenILS/Application/Cat/AssetCommon.pm
@@ -60,7 +60,7 @@ sub create_copy {
my $evt;
my $org = (ref $copy->circ_lib) ? $copy->circ_lib->id : $copy->circ_lib;
- return $evt if ($evt = OpenILS::Application::Cat::AssetCommon->org_cannot_have_vols($editor, $org));
+ return $evt if ($evt = $class->org_cannot_have_vols($editor, $org));
$copy->clear_id;
$copy->editor($editor->requestor->id);
@@ -196,7 +196,7 @@ sub update_copy {
my $evt;
my $org = (ref $copy->circ_lib) ? $copy->circ_lib->id : $copy->circ_lib;
- return $evt if ( $evt = OpenILS::Application::Cat::AssetCommon->org_cannot_have_vols($editor, $org) );
+ return $evt if ( $evt = $class->org_cannot_have_vols($editor, $org) );
$logger->info("vol-update: updating copy ".$copy->id);
my $orig_copy = $editor->retrieve_asset_copy($copy->id);
@@ -313,7 +313,7 @@ sub update_fleshed_copies {
sub delete_copy {
- my($class, $editor, $override, $vol, $copy, $retarget_holds, $force_delete_empty_bib) = @_;
+ my($class, $editor, $override, $vol, $copy, $retarget_holds, $force_delete_empty_bib, $skip_empty_cleanup) = @_;
return $editor->event unless
$editor->allowed('DELETE_COPY', $class->copy_perm_org($vol, $copy));
@@ -346,6 +346,8 @@ sub delete_copy {
$class->check_hold_retarget($editor, $copy, undef, $retarget_holds);
+ return undef if $skip_empty_cleanup;
+
return $class->remove_empty_objects($editor, $override, $vol, $force_delete_empty_bib);
}
@@ -447,7 +449,7 @@ sub find_or_create_volume {
$vol->suffix($suffix);
$vol->record($record_id);
- my $evt = OpenILS::Application::Cat::AssetCommon->create_volume(0, $e, $vol);
+ my $evt = $class->create_volume(0, $e, $vol);
return (undef, $evt) if $evt;
return ($vol);
@@ -479,10 +481,8 @@ sub remove_empty_objects {
# delete this volume if it's not already marked as deleted
unless( $U->is_true($vol->deleted) || $vol->isdeleted ) {
- $vol->deleted('t');
- $vol->editor($editor->requestor->id);
- $vol->edit_date('now');
- $editor->update_asset_call_number($vol) or return $editor->event;
+ my $evt = $class->delete_volume($editor, $vol, $override, 0, 1);
+ return $evt if $evt;
}
return OpenILS::Event->new('TITLE_LAST_COPY', payload => $vol->record )
@@ -498,6 +498,37 @@ sub remove_empty_objects {
return undef;
}
+# Deletes a volume. Returns undef on success, event on error
+# force : deletes all attached copies
+# skip_copy_check : assumes caller has verified no copies need deleting first
+sub delete_volume {
+ my($class, $editor, $vol, $override, $delete_copies, $skip_copy_checks) = @_;
+ my $evt;
+
+ unless($skip_copy_checks) {
+ my $cs = $editor->search_asset_copy(
+ [{call_number => $vol->id, deleted => 'f'}, {limit => 1}], {idlist => 1});
+
+ return OpenILS::Event->new('VOLUME_NOT_EMPTY', payload => $vol->id)
+ if @$cs and !$delete_copies;
+
+ my $copies = $editor->search_asset_copy({call_number => $vol->id, deleted => 'f'});
+
+ for my $copy (@$copies) {
+ $evt = $class->delete_copy($editor, $override, $vol, $copy, 0, 0, 1);
+ return $evt if $evt;
+ }
+ }
+
+ $vol->deleted('t');
+ $vol->edit_date('now');
+ $vol->editor($editor->requestor->id);
+ $editor->update_asset_call_number($vol) or return $editor->die_event;
+
+ # handle the case where this is the last volume on the record
+ return $class->remove_empty_objects($editor, $override, $vol);
+}
+
sub copy_perm_org {
my($class, $vol, $copy) = @_;
-----------------------------------------------------------------------
Summary of changes:
.../src/perlmods/lib/OpenILS/Application/Cat.pm | 20 ++--
.../lib/OpenILS/Application/Cat/AssetCommon.pm | 136 ++++++++++++++++++--
.../lib/OpenILS/Application/Cat/BibCommon.pm | 26 ++++
Open-ILS/src/sql/Pg/002.schema.config.sql | 2 +-
Open-ILS/src/sql/Pg/950.data.seed-values.sql | 40 ++++++
...data.org-setting-cat.volume.delete_on_empty.sql | 19 +++
...finition.hold-cancel-no-target-notification.sql | 39 ++++++
.../xul/staff_client/server/cat/copy_browser.js | 49 +++++---
.../xul/staff_client/server/circ/copy_status.js | 47 +++++---
.../server/locale/en-US/cat.properties | 4 +-
.../server/locale/en-US/circ.properties | 4 +-
11 files changed, 330 insertions(+), 56 deletions(-)
create mode 100644 Open-ILS/src/sql/Pg/upgrade/0564.data.org-setting-cat.volume.delete_on_empty.sql
create mode 100644 Open-ILS/src/sql/Pg/upgrade/0565.schema.action-trigger.event_definition.hold-cancel-no-target-notification.sql
hooks/post-receive
--
Evergreen ILS
More information about the open-ils-commits
mailing list