From b09ad8fd9ccf37b374ddf9840cf20fc63f45a624 Mon Sep 17 00:00:00 2001 From: Galen Charlton Date: Wed, 3 Aug 2016 12:18:19 -0400 Subject: [PATCH] LP#1356477: seed data for email checkout receipts This patch adds seed data for email checkout receipts, including: - The action/trigger hooks circ.checkout.batch_notify and circ.checkout.batch_notify.session. - The default event definition - The circ.send_email_checkout_receipts (Email checkout receipts by default?) user setting. Signed-off-by: Galen Charlton Signed-off-by: Mike Rylander Conflicts: Open-ILS/src/sql/Pg/950.data.seed-values.sql --- Open-ILS/src/sql/Pg/950.data.seed-values.sql | 102 +++++++++++++++++ .../XXXX.data.email-checkout-receipt.sql | 103 ++++++++++++++++++ 2 files changed, 205 insertions(+) create mode 100644 Open-ILS/src/sql/Pg/upgrade/XXXX.data.email-checkout-receipt.sql 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 dbbbdde49a..72b7029d9b 100644 --- a/Open-ILS/src/sql/Pg/950.data.seed-values.sql +++ b/Open-ILS/src/sql/Pg/950.data.seed-values.sql @@ -16349,6 +16349,7 @@ INSERT INTO actor.org_unit_setting ( 'true' ); +<<<<<<< HEAD INSERT INTO config.global_flag (name, enabled, label) VALUES ( 'ingest.disable_authority_auto_update_bib_meta', FALSE, oils_i18n_gettext( @@ -16360,3 +16361,104 @@ INSERT INTO config.global_flag (name, enabled, label) VALUES ( ) ); +======= +-- email checkout receipts +INSERT INTO config.usr_setting_type ( + name, + opac_visible, + label, + description, + datatype +) VALUES ( + 'circ.send_email_checkout_receipts', + TRUE, + oils_i18n_gettext('circ.send_email_checkout_receipts', 'Email checkout receipts by default?', 'cust', 'label'), + oils_i18n_gettext('circ.send_email_checkout_receipts', 'Email checkout receipts by default?', 'cust', 'description'), + 'bool' +); + +INSERT INTO action_trigger.hook (key, core_type, description, passive) +VALUES ( + 'circ.checkout.batch_notify', + 'circ', + oils_i18n_gettext( + 'circ.checkout.batch_notify', + 'Notification of a group of circs', + 'ath', + 'description' + ), + FALSE +); + +INSERT INTO action_trigger.hook (key, core_type, description, passive) +VALUES ( + 'circ.checkout.batch_notify.session', + 'circ', + oils_i18n_gettext( + 'circ.checkout.batch_notify.session', + 'Notification of a group of circs at the end of a checkout session', + 'ath', + 'description' + ), + FALSE +); + +INSERT INTO action_trigger.event_definition ( + active, + owner, + name, + hook, + validator, + reactor, + usr_field, + opt_in_setting, + group_field, + template +) VALUES ( + TRUE, + 1, + 'Email Checkout Receipt', + 'circ.checkout.batch_notify.session', + 'NOOP_True', + 'SendEmail', + 'usr', + 'circ.send_email_checkout_receipts', + 'usr', + $$[%- USE date -%] +[%- user = target.0.usr -%] +To: [%- params.recipient_email || user.email %] +From: [%- helpers.get_org_setting(target.0.circ_lib.id, 'org.bounced_emails') || params.sender_email || default_sender %] +Subject: Checkout Receipt +Auto-Submitted: auto-generated + +You checked out the following items: + +[% FOR circ IN target %] + [%- copy_details = helpers.get_copy_bib_basics(circ.target_copy.id) -%] + Title: [% copy_details.title %] + Author: [% copy_details.author %] + Call Number: [% circ.target_copy.call_number.label %] + Barcode: [% circ.target_copy.barcode %] + Due: [% date.format(helpers.format_date(circ.due_date), '%Y-%m-%d') %] + Library: [% circ.circ_lib.name %] + +[% END %] +$$); + +INSERT INTO action_trigger.environment ( + event_def, + path +) VALUES ( + currval('action_trigger.event_definition_id_seq'), + 'target_copy.call_number' +), ( + currval('action_trigger.event_definition_id_seq'), + 'target_copy.location' +), ( + currval('action_trigger.event_definition_id_seq'), + 'usr' +), ( + currval('action_trigger.event_definition_id_seq'), + 'circ_lib' +); +>>>>>>> a452d2f... LP#1356477: seed data for email checkout receipts diff --git a/Open-ILS/src/sql/Pg/upgrade/XXXX.data.email-checkout-receipt.sql b/Open-ILS/src/sql/Pg/upgrade/XXXX.data.email-checkout-receipt.sql new file mode 100644 index 0000000000..eaeaf367a7 --- /dev/null +++ b/Open-ILS/src/sql/Pg/upgrade/XXXX.data.email-checkout-receipt.sql @@ -0,0 +1,103 @@ +BEGIN; + +INSERT INTO config.usr_setting_type ( + name, + opac_visible, + label, + description, + datatype +) VALUES ( + 'circ.send_email_checkout_receipts', + TRUE, + oils_i18n_gettext('circ.send_email_checkout_receipts', 'Email checkout receipts by default?', 'cust', 'label'), + oils_i18n_gettext('circ.send_email_checkout_receipts', 'Email checkout receipts by default?', 'cust', 'description'), + 'bool' +); + +INSERT INTO action_trigger.hook (key, core_type, description, passive) +VALUES ( + 'circ.checkout.batch_notify', + 'circ', + oils_i18n_gettext( + 'circ.checkout.batch_notify', + 'Notification of a group of circs', + 'ath', + 'description' + ), + FALSE +); + +INSERT INTO action_trigger.hook (key, core_type, description, passive) +VALUES ( + 'circ.checkout.batch_notify.session', + 'circ', + oils_i18n_gettext( + 'circ.checkout.batch_notify.session', + 'Notification of a group of circs at the end of a checkout session', + 'ath', + 'description' + ), + FALSE +); + +INSERT INTO action_trigger.event_definition ( + active, + owner, + name, + hook, + validator, + reactor, + usr_field, + opt_in_setting, + group_field, + template +) VALUES ( + TRUE, + 1, + 'Email Checkout Receipt', + 'circ.checkout.batch_notify.session', + 'NOOP_True', + 'SendEmail', + 'usr', + 'circ.send_email_checkout_receipts', + 'usr', + $$[%- USE date -%] +[%- user = target.0.usr -%] +To: [%- params.recipient_email || user.email %] +From: [%- helpers.get_org_setting(target.0.circ_lib.id, 'org.bounced_emails') || params.sender_email || default_sender %] +Subject: Checkout Receipt +Auto-Submitted: auto-generated + +You checked out the following items: + +[% FOR circ IN target %] + [%- copy_details = helpers.get_copy_bib_basics(circ.target_copy.id) -%] + Title: [% copy_details.title %] + Author: [% copy_details.author %] + Call Number: [% circ.target_copy.call_number.label %] + Barcode: [% circ.target_copy.barcode %] + Due: [% date.format(helpers.format_date(circ.due_date), '%Y-%m-%d') %] + Library: [% circ.circ_lib.name %] + +[% END %] +$$); + +INSERT INTO action_trigger.environment ( + event_def, + path +) VALUES ( + currval('action_trigger.event_definition_id_seq'), + 'target_copy.call_number' +), ( + currval('action_trigger.event_definition_id_seq'), + 'target_copy.location' +), ( + currval('action_trigger.event_definition_id_seq'), + 'usr' +), ( + currval('action_trigger.event_definition_id_seq'), + 'circ_lib' +); + +COMMIT; + -- 2.43.2