JBAS-886 Student groups and policies SQL
authorBill Erickson <berickxx@gmail.com>
Wed, 16 Sep 2015 15:15:28 +0000 (11:15 -0400)
committerBill Erickson <berickxx@gmail.com>
Thu, 21 Mar 2019 19:46:23 +0000 (15:46 -0400)
Schools
 -- Student Ecards
 -- Classroom Cards

Signed-off-by: Bill Erickson <berickxx@gmail.com>
KCLS/sql/schema/deploy/student-groups.sql [new file with mode: 0644]
KCLS/sql/schema/revert/student-groups.sql [new file with mode: 0644]
KCLS/sql/schema/sqitch.plan
KCLS/sql/schema/verify/student-groups.sql [new file with mode: 0644]

diff --git a/KCLS/sql/schema/deploy/student-groups.sql b/KCLS/sql/schema/deploy/student-groups.sql
new file mode 100644 (file)
index 0000000..05d2de3
--- /dev/null
@@ -0,0 +1,67 @@
+-- Deploy kcls-evergreen:student-groups to pg
+-- requires: blanket-po
+
+BEGIN;
+
+DO $$
+BEGIN
+    IF evergreen.insert_on_deploy() THEN
+
+INSERT INTO permission.perm_list (code, description) VALUES 
+    (   'group_application.user.students', 
+        'Allows staff to create and modify student accounts'),
+    (   'ACCESS_EBOOKS_AND_DATABASES',
+        'Allows patrons to access digital materials');
+
+INSERT INTO permission.grp_tree 
+    (id, name, parent, usergroup, perm_interval, description, application_perm) 
+VALUES (
+    900, 'Schools', 1, FALSE, '2 years', 
+    'Parent group of all student groups', 
+    'group_application.user.students'
+);
+
+INSERT INTO permission.grp_perm_map (grp, perm, depth, grantable) VALUES
+    (2, (SELECT id FROM permission.perm_list 
+            WHERE code = 'ACCESS_EBOOKS_AND_DATABASES'), 0, FALSE),
+    (3, (SELECT id FROM permission.perm_list 
+            WHERE code = 'ACCESS_EBOOKS_AND_DATABASES'), 0, FALSE),
+    (900, (SELECT id FROM permission.perm_list 
+            WHERE code = 'ACCESS_EBOOKS_AND_DATABASES'), 0, FALSE);
+
+INSERT INTO permission.grp_tree 
+    (id, name, parent, usergroup, perm_interval) VALUES 
+    (901, 'Student Ecard', 900, TRUE, '2 years'),
+    (902, 'Classroom Databases', 900, TRUE, '2 years');
+
+PERFORM SETVAL('permission.grp_tree_id_seq', 1000);
+
+INSERT INTO config.circ_matrix_matchpoint 
+    (active, org_unit, grp, circulate) VALUES ( TRUE, 1, 900, FALSE);
+
+INSERT INTO config.hold_matrix_matchpoint (
+    active, usr_grp, requestor_grp, ref_flag, holdable, 
+    distance_is_from_owner, include_frozen_holds, stop_blocked_user, 
+    strict_ou_match
+) VALUES (TRUE, 900, 1, FALSE, FALSE, FALSE, FALSE, FALSE, FALSE);
+
+
+-- modify OPAC_LOGIN perm so that's not applied to Users, 
+-- but certain sub-groups.
+DELETE FROM permission.grp_perm_map WHERE perm = 2 AND grp = 1;
+INSERT INTO permission.grp_perm_map (perm, grp, depth) VALUES
+    (2, 2, 0), -- Patrons
+    (2, 3, 0), -- Staff
+    (2, 888, 0); -- SIP
+
+-- new ident type for students
+INSERT INTO config.identification_type (id, name) 
+    VALUES (101, 'Sch-district file');
+
+PERFORM SETVAL('config.identification_type_id_seq', 101);
+
+    END IF; -- insert_on_deploy
+END $$;
+
+COMMIT;
+
diff --git a/KCLS/sql/schema/revert/student-groups.sql b/KCLS/sql/schema/revert/student-groups.sql
new file mode 100644 (file)
index 0000000..afc4eaf
--- /dev/null
@@ -0,0 +1,42 @@
+-- Revert kcls-evergreen:student-groups from pg
+
+BEGIN;
+
+DO $$
+BEGIN
+    IF evergreen.insert_on_deploy() THEN
+
+DELETE FROM config.hold_matrix_matchpoint WHERE usr_grp = 900;
+
+DELETE FROM config.circ_matrix_matchpoint WHERE grp = 900;
+
+DELETE FROM permission.grp_perm_map WHERE perm = 
+    (SELECT id FROM permission.perm_list 
+        WHERE code = 'ACCESS_EBOOKS_AND_DATABASES');
+
+DELETE FROM permission.grp_tree WHERE parent = 900;
+
+DELETE FROM permission.grp_tree WHERE id = 900;
+
+PERFORM SETVAL('permission.grp_tree_id_seq', 1000);
+
+DELETE FROM permission.perm_list WHERE code IN (
+    'group_application.user.students',
+    'ACCESS_EBOOKS_AND_DATABASES'
+);
+
+DELETE FROM permission.grp_perm_map WHERE 
+    (perm = 2 AND grp = 2) OR
+    (perm = 2 AND grp = 3) OR
+    (perm = 2 AND grp = 888);
+
+INSERT INTO permission.grp_perm_map (perm, grp, depth) VALUES (2, 1, 0);
+
+DELETE FROM config.identification_type WHERE id = 101;
+
+PERFORM SETVAL('config.identification_type_id_seq', 100);
+
+    END IF; -- insert-on-deploy
+END $$;
+
+COMMIT;
index a63a4c3..127d754 100644 (file)
@@ -12,3 +12,4 @@ insert-on-deploy [KMAIN-1765-reingest-causing-false-browse-headings] 2015-08-14T
 copy-stat-checkout-ok [insert-on-deploy] 2015-08-14T20:47:19Z Bill Erickson  <berickxx@gmail.com > # copy_status.checkout_ok flag for Grand Opening
 blanket-po [copy-stat-checkout-ok] 2015-08-14T21:03:02Z Bill Erickson  <berickxx@gmail.com > # Blanket PO
 collection-hq-floating-case [blanket-po] 2015-09-17T18:42:09Z Bill Erickson <berickxx@gmail.com> # CollectionHQ floating CASE/WHEN fix
+student-groups [blanket-po] 2015-09-16T14:36:00Z Bill Erickson <berickxx@gmail.com> # New groups for student cards
diff --git a/KCLS/sql/schema/verify/student-groups.sql b/KCLS/sql/schema/verify/student-groups.sql
new file mode 100644 (file)
index 0000000..d631650
--- /dev/null
@@ -0,0 +1,7 @@
+-- Verify kcls-evergreen:student-groups on pg
+
+BEGIN;
+
+-- XXX Add verifications here.
+
+ROLLBACK;