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>
"active":"t",
"deleted":"f"
}
+ },
+ "stgu.created" : {
+ "context_org": "home_ou",
+ "filter": {
+ "complete": "f"
+ }
}
}
</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>
-- 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)
--- /dev/null
+\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
--- /dev/null
+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
--- /dev/null
+== 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