From 0c414a2e9253f5e7b457c9b9a30fc3444eb5f26f Mon Sep 17 00:00:00 2001 From: Jane Sandberg Date: Sat, 9 Jan 2021 22:20:29 -0800 Subject: [PATCH] LP1910891: Add new booking perms to appropriate groups Steps to test: 1) Without this patch, create a reservation for a BR1 resource at BR1. 2) Log in as a circulator at BR1. 3) Go to Booking > Manage Reservations. Note that you can't see your reservation. 4) Run this upgrade script. 5) Repeat steps 2-3. Notice that you can now see the reservation. 6) Wipe your database and re-install it with the additions to the seed data in this commit. Repeat steps 1-3 and notice that you can see the reservation as expected. Signed-off-by: Jane Sandberg Signed-off-by: Terran McCanna Signed-off-by: Galen Charlton --- Open-ILS/src/sql/Pg/950.data.seed-values.sql | 4 +++ .../Pg/upgrade/XXXX.new_booking_perms_in_map.sql | 29 ++++++++++++++++++++++ 2 files changed, 33 insertions(+) create mode 100644 Open-ILS/src/sql/Pg/upgrade/XXXX.new_booking_perms_in_map.sql 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 612fcc7d36..e2c79ef51b 100644 --- a/Open-ILS/src/sql/Pg/950.data.seed-values.sql +++ b/Open-ILS/src/sql/Pg/950.data.seed-values.sql @@ -2396,6 +2396,8 @@ INSERT INTO permission.grp_perm_map (grp, perm, depth, grantable) 'UPDATE_PICKUP_LIB_FROM_HOLDS_SHELF', 'VIEW_BOOKING_RESOURCE', 'VIEW_BOOKING_RESOURCE_TYPE', + 'VIEW_BOOKING_RESERVATION', + 'VIEW_BOOKING_RESERVATION_ATTR_MAP', 'VIEW_GROUP_PENALTY_THRESHOLD', 'VIEW_STANDING_PENALTY', 'VOID_BILLING', @@ -2560,6 +2562,8 @@ INSERT INTO permission.grp_perm_map (grp, perm, depth, grantable) 'UPDATE_USER', 'VIEW_BOOKING_RESOURCE', 'VIEW_BOOKING_RESOURCE_TYPE', + 'VIEW_BOOKING_RESERVATION', + 'VIEW_BOOKING_RESERVATION_ATTR_MAP', 'VIEW_REPORT_OUTPUT', 'VIEW_STANDING_PENALTY', 'VOID_BILLING', diff --git a/Open-ILS/src/sql/Pg/upgrade/XXXX.new_booking_perms_in_map.sql b/Open-ILS/src/sql/Pg/upgrade/XXXX.new_booking_perms_in_map.sql new file mode 100644 index 0000000000..56db2ee23a --- /dev/null +++ b/Open-ILS/src/sql/Pg/upgrade/XXXX.new_booking_perms_in_map.sql @@ -0,0 +1,29 @@ +BEGIN; + +--- SELECT evergreen.upgrade_deps_block_check('XXXX', :eg_version); + +WITH perms_to_add AS + (SELECT id FROM + permission.perm_list + WHERE code IN ('VIEW_BOOKING_RESERVATION', 'VIEW_BOOKING_RESERVATION_ATTR_MAP')) + +INSERT INTO permission.grp_perm_map (grp, perm, depth, grantable) + SELECT grp, perms_to_add.id as perm, depth, grantable + FROM perms_to_add, + permission.grp_perm_map + + --- Don't add the permissions if they have already been assigned + WHERE grp NOT IN + (SELECT DISTINCT grp FROM permission.grp_perm_map + INNER JOIN perms_to_add ON perm=perms_to_add.id) + + --- Anybody who can view resources should also see reservations + --- at the same level + AND perm = ( + SELECT id + FROM permission.perm_list + WHERE code = 'VIEW_BOOKING_RESOURCE' + ); + + +COMMIT; -- 2.11.0