LP#1849736: Stamping upgrade script
authorChris Sharp <csharp@georgialibraries.org>
Mon, 24 Feb 2020 16:02:28 +0000 (11:02 -0500)
committerChris Sharp <csharp@georgialibraries.org>
Mon, 24 Feb 2020 16:02:28 +0000 (11:02 -0500)
Signed-off-by: Chris Sharp <csharp@georgialibraries.org>
Open-ILS/src/sql/Pg/002.schema.config.sql
Open-ILS/src/sql/Pg/upgrade/1199.lp1849736_at_email_self_register.sql [new file with mode: 0755]

index 6715c8c..86b2d68 100644 (file)
@@ -92,7 +92,7 @@ CREATE TRIGGER no_overlapping_deps
     BEFORE INSERT OR UPDATE ON config.db_patch_dependencies
     FOR EACH ROW EXECUTE PROCEDURE evergreen.array_overlap_check ('deprecates');
 
-INSERT INTO config.upgrade_log (version, applied_to) VALUES ('1198', :eg_version); -- berick/tmccanna
+INSERT INTO config.upgrade_log (version, applied_to) VALUES ('1199', :eg_version); -- Bmagic/csharp
 
 CREATE TABLE config.bib_source (
        id              SERIAL  PRIMARY KEY,
diff --git a/Open-ILS/src/sql/Pg/upgrade/1199.lp1849736_at_email_self_register.sql b/Open-ILS/src/sql/Pg/upgrade/1199.lp1849736_at_email_self_register.sql
new file mode 100755 (executable)
index 0000000..6b95c3f
--- /dev/null
@@ -0,0 +1,47 @@
+BEGIN;
+
+
+SELECT evergreen.upgrade_deps_block_check('1199', :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;