LP#1124498: Stamping upgrade script for 30 day pre-expiration notice
authorBen Shum <bshum@biblio.org>
Wed, 19 Aug 2015 18:49:45 +0000 (14:49 -0400)
committerBen Shum <bshum@biblio.org>
Wed, 19 Aug 2015 18:49:45 +0000 (14:49 -0400)
Signed-off-by: Ben Shum <bshum@biblio.org>
Open-ILS/src/sql/Pg/002.schema.config.sql
Open-ILS/src/sql/Pg/upgrade/0939.30day.expiration.prenotice.sql [new file with mode: 0644]
Open-ILS/src/sql/Pg/upgrade/XXXX.30day.expiration.prenotice.sql [deleted file]

index 9eeb542..9aff082 100644 (file)
@@ -91,7 +91,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 ('0938', :eg_version); -- gmcharlt/miker/berick/phasefx/dyrcona
+INSERT INTO config.upgrade_log (version, applied_to) VALUES ('0939', :eg_version); -- mrpeters/stompro/mmorgan/bshum
 
 CREATE TABLE config.bib_source (
        id              SERIAL  PRIMARY KEY,
diff --git a/Open-ILS/src/sql/Pg/upgrade/0939.30day.expiration.prenotice.sql b/Open-ILS/src/sql/Pg/upgrade/0939.30day.expiration.prenotice.sql
new file mode 100644 (file)
index 0000000..0f726c1
--- /dev/null
@@ -0,0 +1,55 @@
+BEGIN;
+
+SELECT evergreen.upgrade_deps_block_check('0939', :eg_version);
+
+--create hook for actor.usr.expire_date
+INSERT INTO action_trigger.hook (key, core_type, description, passive)
+    VALUES ('au.expired', 'au', 'A user account has expired', 't');
+       
+--SQL to create event definition for 30 day account pre-expiration notice
+--Inactive, owned by top of org tree by default.  Modify to suit needs.
+--Can set reactor to 'ProcessTemplate' for testing.  Will generate emails in DB, but not actually send.
+
+INSERT INTO action_trigger.event_definition (
+    active, owner, name, hook, 
+    validator, reactor, delay, delay_field,
+    max_delay, repeat_delay, template
+)  VALUES (
+    'f', '1', '30 Day Account Expiration Courtesy Notice', 'au.expired',
+    'NOOP_True', 'SendEmail', '-30 days', 'expire_date',
+    '-29 days', '30 days',
+$$
+[%- USE date -%]
+[%- user = target -%]
+[%- lib = target.home_ou -%]
+To: [%- params.recipient_email || user.email %]
+From: [%- helpers.get_org_setting(target.home_ou.id, 'org.bounced_emails') || lib.email || params.sender_email || default_sender %]
+Reply-To: [%- helpers.get_org_setting(target.home_ou.id, 'org.bounced_emails') || lib.email || params.sender_email || default_sender %]
+Subject: Courtesy Notice - Library Account Expiration in 30 days
+Auto-Submitted: auto-generated
+
+Dear [% user.first_given_name %] [% user.family_name %],
+
+Our records indicate your library account is due to expire in 30 days.  Please visit your local library at your convenience to renew your account in order to avoid a disruption in access to library service.
+
+Sincerely,
+[% lib.name %]
+
+Contact your library for more information:
+
+[% lib.name %]
+[%- SET addr = lib.mailing_address -%]
+[%- IF !addr -%] [%- SET addr = lib.billing_address -%] [%- END %]
+[% addr.street1 %] [% addr.street2 %]
+[% addr.city %], [% addr.state %]
+[% addr.post_code %]
+[% lib.phone %]
+
+$$);
+       
+--insert environment values
+INSERT INTO action_trigger.environment (event_def, path) VALUES
+    (CURRVAL('action_trigger.event_definition_id_seq'), 'home_ou.mailing_address'),
+    (CURRVAL('action_trigger.event_definition_id_seq'), 'home_ou.billing_address');
+       
+COMMIT;
diff --git a/Open-ILS/src/sql/Pg/upgrade/XXXX.30day.expiration.prenotice.sql b/Open-ILS/src/sql/Pg/upgrade/XXXX.30day.expiration.prenotice.sql
deleted file mode 100644 (file)
index a1d9ac5..0000000
+++ /dev/null
@@ -1,53 +0,0 @@
-BEGIN;
-
---create hook for actor.usr.expire_date
-INSERT INTO action_trigger.hook (key, core_type, description, passive)
-    VALUES ('au.expired', 'au', 'A user account has expired', 't');
-       
---SQL to create event definition for 30 day account pre-expiration notice
---Inactive, owned by top of org tree by default.  Modify to suit needs.
---Can set reactor to 'ProcessTemplate' for testing.  Will generate emails in DB, but not actually send.
-
-INSERT INTO action_trigger.event_definition (
-    active, owner, name, hook, 
-    validator, reactor, delay, delay_field,
-    max_delay, repeat_delay, template
-)  VALUES (
-    'f', '1', '30 Day Account Expiration Courtesy Notice', 'au.expired',
-    'NOOP_True', 'SendEmail', '-30 days', 'expire_date',
-    '-29 days', '30 days',
-$$
-[%- USE date -%]
-[%- user = target -%]
-[%- lib = target.home_ou -%]
-To: [%- params.recipient_email || user.email %]
-From: [%- helpers.get_org_setting(target.home_ou.id, 'org.bounced_emails') || lib.email || params.sender_email || default_sender %]
-Reply-To: [%- helpers.get_org_setting(target.home_ou.id, 'org.bounced_emails') || lib.email || params.sender_email || default_sender %]
-Subject: Courtesy Notice - Library Account Expiration in 30 days
-Auto-Submitted: auto-generated
-
-Dear [% user.first_given_name %] [% user.family_name %],
-
-Our records indicate your library account is due to expire in 30 days.  Please visit your local library at your convenience to renew your account in order to avoid a disruption in access to library service.
-
-Sincerely,
-[% lib.name %]
-
-Contact your library for more information:
-
-[% lib.name %]
-[%- SET addr = lib.mailing_address -%]
-[%- IF !addr -%] [%- SET addr = lib.billing_address -%] [%- END %]
-[% addr.street1 %] [% addr.street2 %]
-[% addr.city %], [% addr.state %]
-[% addr.post_code %]
-[% lib.phone %]
-
-$$);
-       
---insert environment values
-INSERT INTO action_trigger.environment (event_def, path) VALUES
-    (CURRVAL('action_trigger.event_definition_id_seq'), 'home_ou.mailing_address'),
-    (CURRVAL('action_trigger.event_definition_id_seq'), 'home_ou.billing_address');
-       
-COMMIT;