From 93a1554204c141fb294c8a900f7f136f4e035173 Mon Sep 17 00:00:00 2001 From: Bill Erickson Date: Thu, 26 Jul 2018 10:56:40 -0400 Subject: [PATCH] JBAS-2018 eCard UMS print notice validator Confirm patrons are un-purged and un-verified before sending to UMS for ecard letter generation. Signed-off-by: Bill Erickson --- KCLS/sql/schema/deploy/ecard-notice-validator.sql | 33 ++++++++++++++++++++++ KCLS/sql/schema/revert/ecard-notice-validator.sql | 21 ++++++++++++++ KCLS/sql/schema/sqitch.plan | 1 + .../lib/OpenILS/Application/Trigger/Validator.pm | 10 +++++++ 4 files changed, 65 insertions(+) create mode 100644 KCLS/sql/schema/deploy/ecard-notice-validator.sql create mode 100644 KCLS/sql/schema/revert/ecard-notice-validator.sql diff --git a/KCLS/sql/schema/deploy/ecard-notice-validator.sql b/KCLS/sql/schema/deploy/ecard-notice-validator.sql new file mode 100644 index 0000000000..8b06cf3d3f --- /dev/null +++ b/KCLS/sql/schema/deploy/ecard-notice-validator.sql @@ -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 index 0000000000..0fb44d104f --- /dev/null +++ b/KCLS/sql/schema/revert/ecard-notice-validator.sql @@ -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; diff --git a/KCLS/sql/schema/sqitch.plan b/KCLS/sql/schema/sqitch.plan index b758b3ac51..a71d6a2934 100644 --- a/KCLS/sql/schema/sqitch.plan +++ b/KCLS/sql/schema/sqitch.plan @@ -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,,, # Invoice export by/date fields ecard-data [2.10-to-2.12-upgrade] 2018-01-03T21:55:03Z Bill Erickson,,, # Ecard lib settings, policy data, etc. remove-gender [ecard-data] 2018-06-06T14:44:36Z Bill Erickson,,, # Remove gender field/data +ecard-notice-validator [remove-gender] 2018-07-26T14:33:57Z Bill Erickson,,, # eCard UMS notice validator diff --git a/Open-ILS/src/perlmods/lib/OpenILS/Application/Trigger/Validator.pm b/Open-ILS/src/perlmods/lib/OpenILS/Application/Trigger/Validator.pm index ad4e4f4fb6..14937812ee 100644 --- a/Open-ILS/src/perlmods/lib/OpenILS/Application/Trigger/Validator.pm +++ b/Open-ILS/src/perlmods/lib/OpenILS/Application/Trigger/Validator.pm @@ -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; -- 2.11.0