fix constraint syntax
authorJason Etheridge <jason@esilibrary.com>
Tue, 20 Mar 2012 17:03:21 +0000 (13:03 -0400)
committerThomas Berezansky <tsbere@mvlc.org>
Wed, 28 Mar 2012 19:32:33 +0000 (15:32 -0400)
and add in toolbar related permissions, plus a missing and unrelated perm: IMPORT_AUTHORITY_MARC

Signed-off-by: Jason Etheridge <jason@esilibrary.com>
Signed-off-by: Thomas Berezansky <tsbere@mvlc.org>
Open-ILS/src/sql/Pg/005.schema.actors.sql
Open-ILS/src/sql/Pg/950.data.seed-values.sql
Open-ILS/src/sql/Pg/upgrade/XXXX.schema.custom_toolbars.sql

index 4fead81..a6edeb9 100644 (file)
@@ -637,9 +637,6 @@ CREATE TABLE actor.toolbar (
     usr         INT         REFERENCES actor.usr (id) ON DELETE CASCADE,
     label       TEXT        NOT NULL,
     layout      TEXT        NOT NULL,
-       CONSTRAINT label_once_per_ws UNIQUE (ws, label) WHERE ws IS NOT NULL,
-       CONSTRAINT label_once_per_org UNIQUE (org, label) WHERE org IS NOT NULL,
-       CONSTRAINT label_once_per_usr UNIQUE (usr, label) WHERE usr IS NOT NULL,
     CONSTRAINT only_one_type CHECK (
         (ws IS NOT NULL AND COALESCE(org,usr) IS NULL) OR
         (org IS NOT NULL AND COALESCE(ws,usr) IS NULL) OR
@@ -647,5 +644,8 @@ CREATE TABLE actor.toolbar (
     ),
     CONSTRAINT layout_must_be_json CHECK ( is_json(layout) )
 );
+CREATE UNIQUE INDEX label_once_per_ws ON actor.toolbar (ws, label) WHERE ws IS NOT NULL;
+CREATE UNIQUE INDEX label_once_per_org ON actor.toolbar (org, label) WHERE org IS NOT NULL;
+CREATE UNIQUE INDEX label_once_per_usr ON actor.toolbar (usr, label) WHERE usr IS NOT NULL;
 
 COMMIT;
index 953c02e..b9ebb7e 100644 (file)
@@ -1533,8 +1533,9 @@ INSERT INTO permission.perm_list ( id, code, description ) VALUES
  ( 521, 'IMPORT_ACQ_LINEITEM_BIB_RECORD_UPLOAD', oils_i18n_gettext( 521,
     'Allows a user to create new bibs directly from an ACQ MARC file upload', 'ppl', 'description' )),
  ( 522, 'IMPORT_AUTHORITY_MARC', oils_i18n_gettext( 522,
-    'Allows a user to create new authority records', 'ppl', 'description' ));
-
+    'Allows a user to create new authority records', 'ppl', 'description' )),
+ ( 523, 'ADMIN_TOOLBAR', oils_i18n_gettext( 523,
+    'Allows a user to create, edit, and delete custom toolbars', 'ppl', 'description' ));
 
 SELECT SETVAL('permission.perm_list_id_seq'::TEXT, 1000);
 
@@ -1743,6 +1744,7 @@ INSERT INTO permission.grp_perm_map (grp, perm, depth, grantable)
                        'RENEW_HOLD_OVERRIDE',
                        'UPDATE_COPY',
                        'UPDATE_VOLUME',
+                       'ADMIN_TOOLBAR',
                        'VOLUME_HOLDS');
 
 
@@ -11509,3 +11511,6 @@ INSERT INTO action_trigger.environment (event_def, path)
         'target_copy.call_number'
     );
 
+INSERT INTO actor.toolbar(org,label,layout) VALUES
+    ( 1, 'circ', '["circ_checkout","circ_checkin","toolbarseparator","search_opac","copy_status","toolbarseparator","patron_search","patron_register","toolbarspacer","hotkeys_toggle"]' ),
+    ( 1, 'cat', '["circ_checkin","toolbarseparator","search_opac","copy_status","toolbarseparator","create_marc","authority_manage","retrieve_last_record","toolbarspacer","hotkeys_toggle"]' );
index ae94191..386f052 100644 (file)
@@ -6,9 +6,6 @@ CREATE TABLE actor.toolbar (
     usr         INT         REFERENCES actor.usr (id) ON DELETE CASCADE,
     label       TEXT        NOT NULL,
     layout      TEXT        NOT NULL,
-       CONSTRAINT label_once_per_ws UNIQUE (ws, label) WHERE ws IS NOT NULL,
-       CONSTRAINT label_once_per_org UNIQUE (org, label) WHERE org IS NOT NULL,
-       CONSTRAINT label_once_per_usr UNIQUE (usr, label) WHERE usr IS NOT NULL,
     CONSTRAINT only_one_type CHECK (
         (ws IS NOT NULL AND COALESCE(org,usr) IS NULL) OR
         (org IS NOT NULL AND COALESCE(ws,usr) IS NULL) OR
@@ -16,4 +13,44 @@ CREATE TABLE actor.toolbar (
     ),
     CONSTRAINT layout_must_be_json CHECK ( is_json(layout) )
 );
+CREATE UNIQUE INDEX label_once_per_ws ON actor.toolbar (ws, label) WHERE ws IS NOT NULL;
+CREATE UNIQUE INDEX label_once_per_org ON actor.toolbar (org, label) WHERE org IS NOT NULL;
+CREATE UNIQUE INDEX label_once_per_usr ON actor.toolbar (usr, label) WHERE usr IS NOT NULL;
 
+-- this one unrelated to toolbars but is a gap in the upgrade scripts
+INSERT INTO permission.perm_list ( id, code, description )
+    SELECT
+        522,
+        'IMPORT_AUTHORITY_MARC',
+        oils_i18n_gettext(
+            522,
+            'Allows a user to create new authority records',
+            'ppl',
+            'description'
+        )
+    WHERE NOT EXISTS (
+        SELECT 1
+        FROM permission.perm_list
+        WHERE
+            id = 522
+    );
+
+INSERT INTO permission.perm_list ( id, code, description ) VALUES (
+    523,
+    'ADMIN_TOOLBAR',
+    oils_i18n_gettext(
+        523,
+        'Allows a user to create, edit, and delete custom toolbars',
+        'ppl',
+        'description'
+    )
+);
+
+-- Don't want to assume stock perm groups in an upgrade script, but here for ease of testing
+-- INSERT INTO permission.grp_perm_map (grp, perm, depth, grantable) SELECT pgt.id, perm.id, aout.depth, FALSE FROM permission.grp_tree pgt, permission.perm_list perm, actor.org_unit_type aout WHERE pgt.name = 'Staff' AND aout.name = 'Branch' AND perm.code = 'ADMIN_TOOLBAR';
+
+INSERT INTO actor.toolbar(org,label,layout) VALUES
+    ( 1, 'circ', '["circ_checkout","circ_checkin","toolbarseparator","search_opac","copy_status","toolbarseparator","patron_search","patron_register","toolbarspacer","hotkeys_toggle"]' ),
+    ( 1, 'cat', '["circ_checkin","toolbarseparator","search_opac","copy_status","toolbarseparator","create_marc","authority_manage","retrieve_last_record","toolbarspacer","hotkeys_toggle"]' );
+
+-- delete from permission.grp_perm_map where perm in (select id from permission.perm_list where code ~ 'TOOLBAR'); delete from permission.perm_list where code ~ 'TOOLBAR'; drop table actor.toolbar ;