From: blake Date: Thu, 2 Jan 2020 22:48:45 +0000 (-0600) Subject: LP#1849736 Add action trigger for email/sms for patron self registration X-Git-Url: https://old-git.evergreen-ils.org/?a=commitdiff_plain;h=f1f721ac25bdacf32a7603644ca3c2c1ce12e608;p=evergreen%2Fpines.git LP#1849736 Add action trigger for email/sms for patron self registration Setup a new A/T Hook. Includes: 1. New row in action_trigger.hook 2. New row in action_trigger.event_definition 3. New clause in action_trigger_filters.json.example 4. Link XML clause for oils_obj:fieldmapper="staging::user_stage" on fm_IDL.xml 4. pgTAP Test 5. Release Documentation Signed-off-by: blake Signed-off-by: Terran McCanna Signed-off-by: Chris Sharp --- diff --git a/Open-ILS/examples/action_trigger_filters.json.example b/Open-ILS/examples/action_trigger_filters.json.example index 01f913dd90..c56559f584 100644 --- a/Open-ILS/examples/action_trigger_filters.json.example +++ b/Open-ILS/examples/action_trigger_filters.json.example @@ -40,5 +40,11 @@ "active":"t", "deleted":"f" } + }, + "stgu.created" : { + "context_org": "home_ou", + "filter": { + "complete": "f" + } } } diff --git a/Open-ILS/examples/fm_IDL.xml b/Open-ILS/examples/fm_IDL.xml index 75b52a7597..b32557a9a5 100644 --- a/Open-ILS/examples/fm_IDL.xml +++ b/Open-ILS/examples/fm_IDL.xml @@ -10742,6 +10742,7 @@ SELECT usr, + 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 257117b1d0..b0d5d68875 100644 --- a/Open-ILS/src/sql/Pg/950.data.seed-values.sql +++ b/Open-ILS/src/sql/Pg/950.data.seed-values.sql @@ -10400,6 +10400,56 @@ INSERT INTO action_trigger.environment (event_def, path ) VALUES -- END of autorenwal trigger def stuff + +-- Patron card request definitions and email notification template + +INSERT INTO action_trigger.hook +(key,core_type,description,passive) +VALUES +('stgu.created','stgu','Patron requested a card using self registration','t'); + + +INSERT INTO action_trigger.event_definition(active,owner,name,hook,validator,reactor,delay,max_delay,delay_field,group_field,template,retention_interval) +SELECT 'f',1,'Patron Registered for a card stgu.created','stgu.created','NOOP_True','SendEmail','00:01:00'::interval,'1 day'::interval,'row_date','home_ou',$$ + +[%- USE date -%] +[%- lib = target.0.home_ou -%] +To: [% lib.name %] <[% params.recipient_email || helpers.get_org_setting(target.0.home_ou.id, 'org.bounced_emails') || lib.email || default_sender %]> +From: [% lib.name %] <[% helpers.get_org_setting(target.0.home_ou.id, 'org.bounced_emails') || lib.email || params.recipient_email || default_sender %]> +Date: [% date.format(format => '%a, %d %b %Y %H:%M:%S %Z') %] +Subject: Patron card requested +Auto-Submitted: auto-generated + + +Dear Staff Admin, + +There are some pending patrons waiting for your attention. + +[% FOR patron IN target %] + [% patron.first_given_name %] + +[% END %] + +These requests can be tended via the staff interface. Located "Circulation" -> "Pending Patrons" + + + +$$, +'1 year'::interval + +WHERE NOT EXISTS (SELECT 1 FROM action_trigger.event_definition WHERE name='Patron Registered for a card stgu.created'); + +INSERT INTO action_trigger.environment (event_def,path) +SELECT id,'home_ou' from action_trigger.event_definition WHERE name='Patron Registered for a card stgu.created' +AND NOT EXISTS (SELECT 1 FROM action_trigger.environment WHERE +event_def=(SELECT id FROM action_trigger.event_definition WHERE name='Patron Registered for a card stgu.created' AND owner=1 LIMIT 1) +AND path='home_ou'); + + + +-- END of Patron card request trigger def stuff + + -- Action Trigger for Fine Limit Exceeded-- INSERT INTO action_trigger.event_definition (active, owner, name, hook, validator, reactor, delay, group_field, max_delay, template) diff --git a/Open-ILS/src/sql/Pg/t/lp1849736_at_email_self_register.pg b/Open-ILS/src/sql/Pg/t/lp1849736_at_email_self_register.pg new file mode 100755 index 0000000000..af5ae3246a --- /dev/null +++ b/Open-ILS/src/sql/Pg/t/lp1849736_at_email_self_register.pg @@ -0,0 +1,34 @@ +\unset ECHO +\set QUIET 1 +-- Turn off echo and keep things quiet. + +-- Format the output for nice TAP. +\pset format unaligned +\pset tuples_only true +\pset pager off + +-- Revert all changes on failure. +\set ON_ERROR_ROLLBACK 1 +\set ON_ERROR_STOP true + +-- Load the TAP functions. +BEGIN; + +-- Plan the tests. +SELECT plan(2); + +-- Run the tests. +SELECT isnt_empty( + 'SELECT * FROM action_trigger.hook WHERE key = $$stgu.created$$', + 'A/T Hook stgu.created exists' +); + +SELECT isnt_empty( + 'SELECT * FROM action_trigger.event_definition WHERE owner=1 AND name = $$Patron Registered for a card stgu.created$$', + 'Default consortium ATED for stgu.created exists' +); + + +-- Finish the tests and clean up. +SELECT * FROM finish(); +ROLLBACK; \ No newline at end of file diff --git a/Open-ILS/src/sql/Pg/upgrade/XXXX.lp1849736_at_email_self_register.sql b/Open-ILS/src/sql/Pg/upgrade/XXXX.lp1849736_at_email_self_register.sql new file mode 100755 index 0000000000..799e5d57dd --- /dev/null +++ b/Open-ILS/src/sql/Pg/upgrade/XXXX.lp1849736_at_email_self_register.sql @@ -0,0 +1,48 @@ +BEGIN; + + +SELECT evergreen.upgrade_deps_block_check('XXXX', :eg_version); + +INSERT INTO action_trigger.hook +(key,core_type,description,passive) +VALUES +('stgu.created','stgu','Patron requested a card using self registration','t'); + + +INSERT INTO action_trigger.event_definition(active,owner,name,hook,validator,reactor,delay,max_delay,delay_field,group_field,template,retention_interval) +SELECT 'f',1,'Patron Registered for a card stgu.created','stgu.created','NOOP_True','SendEmail','00:01:00'::interval,'1 day'::interval,'row_date','home_ou',$$ + +[%- USE date -%] +[%- lib = target.0.home_ou -%] +To: [% lib.name %] <[% params.recipient_email || helpers.get_org_setting(target.0.home_ou.id, 'org.bounced_emails') || lib.email || default_sender %]> +From: [% lib.name %] <[% helpers.get_org_setting(target.0.home_ou.id, 'org.bounced_emails') || lib.email || params.recipient_email || default_sender %]> +Date: [% date.format(format => '%a, %d %b %Y %H:%M:%S %Z') %] +Subject: Patron card requested +Auto-Submitted: auto-generated + + +Dear Staff Admin, + +There are some pending patrons waiting for your attention. + +[% FOR patron IN target %] + [% patron.first_given_name %] + +[% END %] + +These requests can be tended via the staff interface. Located "Circulation" -> "Pending Patrons" + + +$$, +'1 year'::interval + +WHERE NOT EXISTS (SELECT 1 FROM action_trigger.event_definition WHERE name='Patron Registered for a card stgu.created'); + +INSERT INTO action_trigger.environment (event_def,path) +SELECT id,'home_ou' from action_trigger.event_definition WHERE name='Patron Registered for a card stgu.created' +AND NOT EXISTS (SELECT 1 FROM action_trigger.environment WHERE +event_def=(SELECT id FROM action_trigger.event_definition WHERE name='Patron Registered for a card stgu.created' AND owner=1 LIMIT 1) +AND path='home_ou'); + + +COMMIT; \ No newline at end of file diff --git a/docs/RELEASE_NOTES_NEXT/Administration/lp1849736_at_email_self_register.adoc b/docs/RELEASE_NOTES_NEXT/Administration/lp1849736_at_email_self_register.adoc new file mode 100755 index 0000000000..480aa0c011 --- /dev/null +++ b/docs/RELEASE_NOTES_NEXT/Administration/lp1849736_at_email_self_register.adoc @@ -0,0 +1,16 @@ +== New Action Trigger hook for patron registration == + +Evergreen now includes a new type of Action Trigger hook: stgu.created. This hook will trigger upon the patron registration submission form. In addition to the new hook, an example Action Trigger definition is provided (disabled) entitled "Patron Registered for a card stgu.created". With clever timing and delay settings, a library can receive a single notification containing all of the pending patron registrations for a given time interval. No special server-side considerations required unless you introduce a new granularity. There is, however, a new clause introduced to the "action_trigger_filters.json.example" file. + +=== Upgrade instructions === + +Be sure and include this clause in your "action_trigger_filters.json.example" file + +---- +"stgu.created" : { + "context_org": "home_ou", + "filter": { + "complete": "f" + } + } +---- \ No newline at end of file