LP#1849736 Add action trigger for email/sms for patron self registration
authorblake <blake@mobiusconsortium.org>
Thu, 2 Jan 2020 22:48:45 +0000 (16:48 -0600)
committerChris Sharp <csharp@georgialibraries.org>
Fri, 21 Feb 2020 18:40:58 +0000 (13:40 -0500)
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 <blake@mobiusconsortium.org>
Signed-off-by: Terran McCanna <tmccanna@georgialibraries.org>
Signed-off-by: Chris Sharp <csharp@georgialibraries.org>
Open-ILS/examples/action_trigger_filters.json.example
Open-ILS/examples/fm_IDL.xml
Open-ILS/src/sql/Pg/950.data.seed-values.sql
Open-ILS/src/sql/Pg/t/lp1849736_at_email_self_register.pg [new file with mode: 0755]
Open-ILS/src/sql/Pg/upgrade/XXXX.lp1849736_at_email_self_register.sql [new file with mode: 0755]
docs/RELEASE_NOTES_NEXT/Administration/lp1849736_at_email_self_register.adoc [new file with mode: 0755]

index 01f913d..c56559f 100644 (file)
             "active":"t",
             "deleted":"f"
         }
+    },
+    "stgu.created" : {
+        "context_org": "home_ou",
+        "filter": {
+            "complete": "f"
+        }
     }
 }
index 75b52a7..b32557a 100644 (file)
@@ -10742,6 +10742,7 @@ SELECT  usr,
         </fields>
         <links>
             <link field="requesting_usr" reltype="has_a" key="id" map="" class="au"/>
+            <link field="home_ou" reltype="has_a" key="id" map="" class="aou"/>
         </links>
     </class>
 
index 257117b..b0d5d68 100644 (file)
@@ -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 (executable)
index 0000000..af5ae32
--- /dev/null
@@ -0,0 +1,34 @@
+\unset ECHO\r
+\set QUIET 1\r
+-- Turn off echo and keep things quiet.\r
+\r
+-- Format the output for nice TAP.\r
+\pset format unaligned\r
+\pset tuples_only true\r
+\pset pager off\r
+\r
+-- Revert all changes on failure.\r
+\set ON_ERROR_ROLLBACK 1\r
+\set ON_ERROR_STOP true\r
+\r
+-- Load the TAP functions.\r
+BEGIN;\r
+\r
+-- Plan the tests.\r
+SELECT plan(2);\r
+\r
+-- Run the tests.\r
+SELECT isnt_empty(\r
+    'SELECT * FROM action_trigger.hook WHERE key = $$stgu.created$$',\r
+    'A/T Hook stgu.created exists'\r
+);\r
+\r
+SELECT isnt_empty(\r
+    'SELECT * FROM action_trigger.event_definition WHERE owner=1 AND name = $$Patron Registered for a card stgu.created$$',\r
+    'Default consortium ATED for stgu.created exists'\r
+);\r
+\r
+\r
+-- Finish the tests and clean up.\r
+SELECT * FROM finish();\r
+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 (executable)
index 0000000..799e5d5
--- /dev/null
@@ -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 (executable)
index 0000000..480aa0c
--- /dev/null
@@ -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