LP1910891: Add new booking perms to appropriate groups
authorJane Sandberg <sandbej@linnbenton.edu>
Sun, 10 Jan 2021 06:20:29 +0000 (22:20 -0800)
committerGalen Charlton <gmc@equinoxOLI.org>
Tue, 13 Jul 2021 14:26:22 +0000 (10:26 -0400)
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 <sandbej@linnbenton.edu>
Signed-off-by: Terran McCanna <tmccanna@georgialibraries.org>
Signed-off-by: Galen Charlton <gmc@equinoxOLI.org>
Open-ILS/src/sql/Pg/950.data.seed-values.sql
Open-ILS/src/sql/Pg/upgrade/XXXX.new_booking_perms_in_map.sql [new file with mode: 0644]

index 612fcc7..e2c79ef 100644 (file)
@@ -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 (file)
index 0000000..56db2ee
--- /dev/null
@@ -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;