JBAS-2018 eCard UMS print notice validator
authorBill Erickson <berickxx@gmail.com>
Thu, 26 Jul 2018 14:56:40 +0000 (10:56 -0400)
committerBill Erickson <berickxx@gmail.com>
Thu, 21 Mar 2019 19:46:23 +0000 (15:46 -0400)
Confirm patrons are un-purged and un-verified before sending to UMS for
ecard letter generation.

Signed-off-by: Bill Erickson <berickxx@gmail.com>
KCLS/sql/schema/deploy/ecard-notice-validator.sql [new file with mode: 0644]
KCLS/sql/schema/revert/ecard-notice-validator.sql [new file with mode: 0644]
KCLS/sql/schema/sqitch.plan
Open-ILS/src/perlmods/lib/OpenILS/Application/Trigger/Validator.pm

diff --git a/KCLS/sql/schema/deploy/ecard-notice-validator.sql b/KCLS/sql/schema/deploy/ecard-notice-validator.sql
new file mode 100644 (file)
index 0000000..8b06cf3
--- /dev/null
@@ -0,0 +1,33 @@
+-- Deploy kcls-evergreen:ecard-notice-validator to pg
+-- requires: remove-gender
+
+BEGIN;
+
+DO $INSERT$
+BEGIN
+    IF evergreen.insert_on_deploy() THEN
+
+        INSERT INTO action_trigger.validator (module, description) VALUES (
+            'PatronIsPendingEcard',
+            'Confirm a patron is a valid candidate for a pending ecard print letter'
+        );
+
+        INSERT INTO action_trigger.event_params (event_def, param, value)
+            VALUES (
+                (   SELECT id FROM action_trigger.event_definition 
+                    WHERE hook = 'au.create.ecard'),
+                'profile',
+                '951' -- Temporary Ecard
+            );
+
+        UPDATE action_trigger.event_definition
+            SET validator = 'PatronIsPendingEcard'
+            WHERE id = (   
+                SELECT id FROM action_trigger.event_definition 
+                WHERE hook = 'au.create.ecard'
+            );
+
+    END IF; -- insert_on_deploy
+END $INSERT$;
+
+COMMIT;
diff --git a/KCLS/sql/schema/revert/ecard-notice-validator.sql b/KCLS/sql/schema/revert/ecard-notice-validator.sql
new file mode 100644 (file)
index 0000000..0fb44d1
--- /dev/null
@@ -0,0 +1,21 @@
+-- Revert kcls-evergreen:ecard-notice-validator on pg
+
+BEGIN;
+
+UPDATE action_trigger.event_definition
+    SET validator = 'NOOP_True'
+    WHERE id = (   
+        SELECT id FROM action_trigger.event_definition 
+        WHERE hook = 'au.create.ecard'
+    );
+
+DELETE FROM action_trigger.validator WHERE module = 'PatronIsPendingEcard';
+
+DELETE FROM action_trigger.event_params WHERE 
+    param = 'profile' AND
+    event_def = (
+        SELECT id FROM action_trigger.event_definition 
+        WHERE hook = 'au.create.ecard'
+    );
+
+COMMIT;
index b758b3a..a71d6a2 100644 (file)
@@ -71,3 +71,4 @@ search-index-keep-periods [vand-import-edit-date-fix] 2018-04-02T19:10:31Z Bill
 acq-inv-close-fields [search-index-keep-periods] 2018-04-12T19:03:29Z Bill Erickson,,, <berick@kcls-dev-local> # Invoice export by/date fields
 ecard-data [2.10-to-2.12-upgrade] 2018-01-03T21:55:03Z Bill Erickson,,, <berick@kcls-dev-local> # Ecard lib settings, policy data, etc.
 remove-gender [ecard-data] 2018-06-06T14:44:36Z Bill Erickson,,, <berick@kcls-dev-local> # Remove gender field/data
+ecard-notice-validator [remove-gender] 2018-07-26T14:33:57Z Bill Erickson,,, <berick@kcls-dev-local> # eCard UMS notice validator
index ad4e4f4..1493781 100644 (file)
@@ -221,4 +221,14 @@ sub CircIsAutoRenewable {
     return 1;
 }
 
+# eCard notifications are sent the day after an ecard registration.
+# Be sure the account was not verified or purged by staff in the meantime.
+sub PatronIsPendingEcard {
+    my ($self, $env) = @_;
+    my $user = $env->{target};
+    my $profile = $env->{params}->{profile} || 951;
+    return $user->deleted eq 'f' && $user->profile == $profile;
+}
+
+
 1;