From 02f8e4409e18b1413edba6351bbc2df5aa02b347 Mon Sep 17 00:00:00 2001 From: Bill Erickson Date: Mon, 22 Apr 2019 08:34:09 -0700 Subject: [PATCH] LP1825851 Server print template SQL sync Propagate SQL upgrade changes to base schema/data files. Signed-off-by: Bill Erickson --- Open-ILS/src/sql/Pg/002.schema.config.sql | 14 +++++++++ Open-ILS/src/sql/Pg/950.data.seed-values.sql | 33 +++++++++++++++++++++- .../upgrade/XXXX.schema.server-print-templates.sql | 26 ++++++----------- 3 files changed, 54 insertions(+), 19 deletions(-) diff --git a/Open-ILS/src/sql/Pg/002.schema.config.sql b/Open-ILS/src/sql/Pg/002.schema.config.sql index 14f4852c3a..dcf5091e26 100644 --- a/Open-ILS/src/sql/Pg/002.schema.config.sql +++ b/Open-ILS/src/sql/Pg/002.schema.config.sql @@ -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; 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 a6fae4dcc7..9520ce378b 100644 --- a/Open-ILS/src/sql/Pg/950.data.seed-values.sql +++ b/Open-ILS/src/sql/Pg/950.data.seed-values.sql @@ -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')) ; @@ -19955,3 +19957,32 @@ VALUES ( 'cwst', 'label') ); +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; +-%] +
+
+ [% patron.first_given_name %] + [% patron.second_given_name %] + [% patron.family_name %] +
+
[% addr.street1 %]
+ [% IF addr.street2 %]
[% addr.street2 %]
[% END %] +
+ [% addr.city %], [% addr.state %] [% addr.post_code %] +
+
+$TEMPLATE$ +); + +-- Allow for 1k stock templates +SELECT SETVAL('config.print_template_id_seq'::TEXT, 1000); + diff --git a/Open-ILS/src/sql/Pg/upgrade/XXXX.schema.server-print-templates.sql b/Open-ILS/src/sql/Pg/upgrade/XXXX.schema.server-print-templates.sql index aaa3f9762c..f191566e82 100644 --- a/Open-ILS/src/sql/Pg/upgrade/XXXX.schema.server-print-templates.sql +++ b/Open-ILS/src/sql/Pg/upgrade/XXXX.schema.server-print-templates.sql @@ -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; -%] -
+
[% 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; -- 2.11.0