From d77cee596c85c8fd87d69204282c7f56cff2fe71 Mon Sep 17 00:00:00 2001 From: Bill Erickson Date: Wed, 1 Jun 2011 17:29:01 -0400 Subject: [PATCH] Permission to allow transit abort on lost/missing This patch introduces a permission that allows staff to abort transits for items in the lost/missing status. Previous, this was disallowed by a hard-coded block. Signed-off-by: Bill Erickson --- .../perlmods/lib/OpenILS/Application/Circ/Transit.pm | 16 ++++++++-------- Open-ILS/src/sql/Pg/002.schema.config.sql | 2 +- Open-ILS/src/sql/Pg/950.data.seed-values.sql | 8 +++++++- .../sql/Pg/upgrade/0545.data.abort_transit_perms.sql | 20 ++++++++++++++++++++ 4 files changed, 36 insertions(+), 10 deletions(-) create mode 100644 Open-ILS/src/sql/Pg/upgrade/0545.data.abort_transit_perms.sql diff --git a/Open-ILS/src/perlmods/lib/OpenILS/Application/Circ/Transit.pm b/Open-ILS/src/perlmods/lib/OpenILS/Application/Circ/Transit.pm index aa3d0448ca..ff4796e97d 100644 --- a/Open-ILS/src/perlmods/lib/OpenILS/Application/Circ/Transit.pm +++ b/Open-ILS/src/perlmods/lib/OpenILS/Application/Circ/Transit.pm @@ -224,16 +224,16 @@ sub __abort_transit { my $evt; my $hold; - if( $transit->copy_status == OILS_COPY_STATUS_LOST or - $transit->copy_status == OILS_COPY_STATUS_MISSING ) { + if( ($transit->copy_status == OILS_COPY_STATUS_LOST and !$e->allowed('ABORT_TRANSIT_ON_LOST')) or + ($transit->copy_status == OILS_COPY_STATUS_MISSING and !$e->allowed('ABORT_TRANSIT_ON_MISSING')) ) { $e->rollback; - return OpenILS::Event->new('TRANSIT_ABORT_NOT_ALLOWED'); + return OpenILS::Event->new('TRANSIT_ABORT_NOT_ALLOWED', copy_status => $transit->copy_status); } if( $transit->dest != $e->requestor->ws_ou and $transit->source != $e->requestor->ws_ou ) { - return $e->event unless $e->allowed('ABORT_REMOTE_TRANSIT', $e->requestor->ws_ou); + return $e->die_event unless $e->allowed('ABORT_REMOTE_TRANSIT', $e->requestor->ws_ou); } # recover the copy status @@ -248,15 +248,15 @@ sub __abort_transit { $copy->status( OILS_COPY_STATUS_RESHELVING ); } - return $e->event unless $e->delete_action_transit_copy($transit); - return $e->event unless $e->update_asset_copy($copy); + return $e->die_event unless $e->delete_action_transit_copy($transit); + return $e->die_event unless $e->update_asset_copy($copy); $e->commit; # if this is a hold transit, un-capture/un-target the hold if($holdtransit and !$no_reset_hold) { - $hold = $e->retrieve_action_hold_request($holdtransit->hold) - or return $e->event; + $hold = $e->retrieve_action_hold_request($holdtransit->hold) + or return $e->die_event; $evt = $holdcode->_reset_hold( $e->requestor, $hold ); return $evt if $evt; } diff --git a/Open-ILS/src/sql/Pg/002.schema.config.sql b/Open-ILS/src/sql/Pg/002.schema.config.sql index 56af82f64a..743be6be86 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 ('0543', :eg_version); -- dbwells +INSERT INTO config.upgrade_log (version, applied_to) VALUES ('0545', :eg_version); -- berick CREATE TABLE config.bib_source ( id SERIAL PRIMARY KEY, 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 5a4b40b404..d80826397a 100644 --- a/Open-ILS/src/sql/Pg/950.data.seed-values.sql +++ b/Open-ILS/src/sql/Pg/950.data.seed-values.sql @@ -1422,7 +1422,11 @@ INSERT INTO permission.perm_list ( id, code, description ) VALUES ( 505, 'UPDATE_WORKSTATION', oils_i18n_gettext(505, 'Allows update of a workstation during workstation registration override.', 'ppl', 'description')), ( 506, 'VIEW_USER_SETTING_TYPE', oils_i18n_gettext(506, - 'Allows viewing of configurable user setting types.', 'ppl', 'description')); + 'Allows viewing of configurable user setting types.', 'ppl', 'description')), + ( 507, 'ABORT_TRANSIT_ON_LOST', oils_i18n_gettext(507, + 'Allows a user to abort a transit on a copy with status of LOST', 'ppl', 'description')), + ( 508, 'ABORT_TRANSIT_ON_MISSING', oils_i18n_gettext(508, + 'Allows a user to abort a transit on a copy with status of MISSING', 'ppl', 'description')); SELECT SETVAL('permission.perm_list_id_seq'::TEXT, 1000); @@ -1905,6 +1909,8 @@ INSERT INTO permission.grp_perm_map (grp, perm, depth, grantable) 'UPDATE_HOLD_REQUEST_TIME', 'UPDATE_NET_ACCESS_LEVEL', 'VIEW_CIRC_MATRIX_MATCHPOINT', + 'ABORT_TRANSIT_ON_LOST', + 'ABORT_TRANSIT_ON_MISSING', 'VIEW_HOLD_MATRIX_MATCHPOINT'); INSERT INTO permission.grp_perm_map (grp, perm, depth, grantable) diff --git a/Open-ILS/src/sql/Pg/upgrade/0545.data.abort_transit_perms.sql b/Open-ILS/src/sql/Pg/upgrade/0545.data.abort_transit_perms.sql new file mode 100644 index 0000000000..917f27a51f --- /dev/null +++ b/Open-ILS/src/sql/Pg/upgrade/0545.data.abort_transit_perms.sql @@ -0,0 +1,20 @@ +BEGIN; + +SELECT evergreen.upgrade_deps_block_check('0545', :eg_version); + +INSERT INTO permission.perm_list VALUES + (507, 'ABORT_TRANSIT_ON_LOST', oils_i18n_gettext(507, 'Allows a user to abort a transit on a copy with status of LOST', 'ppl', 'description')), + (508, 'ABORT_TRANSIT_ON_MISSING', oils_i18n_gettext(508, 'Allows a user to abort a transit on a copy with status of MISSING', 'ppl', 'description')); + +--- stock Circulation Administrator group + +INSERT INTO permission.grp_perm_map ( grp, perm, depth, grantable ) + SELECT + 4, + id, + 0, + 't' + FROM permission.perm_list + WHERE code in ('ABORT_TRANSIT_ON_LOST', 'ABORT_TRANSIT_ON_MISSING'); + +COMMIT; -- 2.11.0