LP1825851 Server print template SQL sync
authorBill Erickson <berickxx@gmail.com>
Mon, 22 Apr 2019 15:34:09 +0000 (08:34 -0700)
committerBill Erickson <berickxx@gmail.com>
Mon, 22 Apr 2019 15:57:40 +0000 (08:57 -0700)
Propagate SQL upgrade changes to base schema/data files.

Signed-off-by: Bill Erickson <berickxx@gmail.com>
Open-ILS/src/sql/Pg/002.schema.config.sql
Open-ILS/src/sql/Pg/950.data.seed-values.sql
Open-ILS/src/sql/Pg/upgrade/XXXX.schema.server-print-templates.sql

index b236d92..039d29f 100644 (file)
@@ -1318,4 +1318,18 @@ CREATE TABLE config.copy_tag_type (
 CREATE INDEX config_copy_tag_type_owner_idx
     ON config.copy_tag_type (owner);
 
+CREATE TABLE config.print_template (
+    id           SERIAL PRIMARY KEY,
+    name         TEXT NOT NULL, 
+    label        TEXT NOT NULL, -- i18n
+    owner        INT NOT NULL REFERENCES actor.org_unit (id),
+    active       BOOLEAN NOT NULL DEFAULT FALSE,
+    locale       TEXT REFERENCES config.i18n_locale(code) 
+                 ON UPDATE CASCADE DEFERRABLE INITIALLY DEFERRED,
+    content_type TEXT NOT NULL DEFAULT 'text/html',
+    template     TEXT NOT NULL,
+       CONSTRAINT   name_once_per_lib UNIQUE (owner, name),
+       CONSTRAINT   label_once_per_lib UNIQUE (owner, label)
+);
+
 COMMIT;
index 3c8a257..3f2d3e5 100644 (file)
@@ -1915,7 +1915,9 @@ INSERT INTO permission.perm_list ( id, code, description ) VALUES
  ( 609, 'MANAGE_CUSTOM_PERM_GRP_TREE', oils_i18n_gettext( 609,
     'Allows a user to manage custom permission group lists.', 'ppl', 'description' )),
  ( 610, 'CLEAR_PURCHASE_REQUEST', oils_i18n_gettext(610,
-    'Clear Completed User Purchase Requests', 'ppl', 'description'))
+    'Clear Completed User Purchase Requests', 'ppl', 'description')),
+ ( 611, 'ADMIN_PRINT_TEMPLATE', oils_i18n_gettext(611,
+    'Modify print templates', 'ppl', 'description'))
 ;
 
 
@@ -19906,3 +19908,33 @@ VALUES (
     )
 );
 
+
+INSERT INTO config.print_template 
+    (id, name, locale, active, owner, label, template) 
+VALUES (
+    1, 'patron_address', 'en-US', FALSE,
+    (SELECT id FROM actor.org_unit WHERE parent_ou IS NULL),
+    oils_i18n_gettext(1, 'Address Label', 'cpt', 'label'),
+$TEMPLATE$
+[%-
+    SET patron = template_data.patron;
+    SET addr = template_data.address;
+-%]
+<div>
+  <div>
+    [% patron.first_given_name %] 
+    [% patron.second_given_name %] 
+    [% patron.family_name %]
+  </div>
+  <div>[% addr.street1 %]</div>
+  [% IF addr.street2 %]<div>[% addr.street2 %]</div>[% END %]
+  <div>
+    [% addr.city %], [% addr.state %] [% addr.post_code %]
+  </div>
+</div>
+$TEMPLATE$
+);
+
+-- Allow for 1k stock templates
+SELECT SETVAL('config.print_template_id_seq'::TEXT, 1000);
+
index aaa3f97..f191566 100644 (file)
@@ -1,18 +1,5 @@
-
 BEGIN;
 
-/*
-No longer have to deliver print templates to the client or store as workstatoin settings
--- trade-off is print data is now sent to the server
-Can define per-locale templates.
-immune to future technology changes
-Angular template modification requires recompiling the Angular build.
-https://metacpan.org/pod/HTML::Restrict
-security concerns of staff modifing templates directly since
-they execute in the borwser context.
-offline caveat
-*/
-
 -- SELECT evergreen.upgrade_deps_block_check('TODO', :eg_version);
 
 CREATE TABLE config.print_template (
@@ -29,9 +16,10 @@ CREATE TABLE config.print_template (
        CONSTRAINT   label_once_per_lib UNIQUE (owner, label)
 );
 
-INSERT INTO config.print_template (id, name, locale, owner, label, template) 
+INSERT INTO config.print_template 
+    (id, name, locale, active, owner, label, template) 
 VALUES (
-    1, 'patron_address', 'en-US',
+    1, 'patron_address', 'en-US', FALSE,
     (SELECT id FROM actor.org_unit WHERE parent_ou IS NULL),
     oils_i18n_gettext(1, 'Address Label', 'cpt', 'label'),
 $TEMPLATE$
@@ -39,7 +27,7 @@ $TEMPLATE$
     SET patron = template_data.patron;
     SET addr = template_data.address;
 -%]
-<div style="font-size:.7em;">
+<div>
   <div>
     [% patron.first_given_name %] 
     [% patron.second_given_name %] 
@@ -54,10 +42,12 @@ $TEMPLATE$
 $TEMPLATE$
 );
 
--- TODO: add print template permission
-
 -- Allow for 1k stock templates
 SELECT SETVAL('config.print_template_id_seq'::TEXT, 1000);
 
+INSERT INTO permission.perm_list (id, code, description) 
+VALUES (611, 'ADMIN_PRINT_TEMPLATE', 
+    oils_i18n_gettext(611, 'Modify print templates', 'ppl', 'description'));
+
 COMMIT;