Patch from Lebbeous Fogle-Weekley to add seed data for a sample hold-shelf-expire...
authorerickson <erickson@dcc99617-32d9-48b4-a31d-7c20da2025e4>
Thu, 12 Nov 2009 21:07:02 +0000 (21:07 +0000)
committererickson <erickson@dcc99617-32d9-48b4-a31d-7c20da2025e4>
Thu, 12 Nov 2009 21:07:02 +0000 (21:07 +0000)
git-svn-id: svn://svn.open-ils.org/ILS/trunk@14885 dcc99617-32d9-48b4-a31d-7c20da2025e4

Open-ILS/examples/action_trigger_filters.json.example
Open-ILS/src/sql/Pg/002.schema.config.sql
Open-ILS/src/sql/Pg/950.data.seed-values.sql
Open-ILS/src/sql/Pg/upgrade/0079.data.hold_request.shelf_expires_soon.sql [new file with mode: 0644]

index 9f56d52..f9b9df8 100644 (file)
@@ -1,5 +1,4 @@
 {
-
 "checkout.due" :
     { "context_org" : "circ_lib",
       "filter"      :
@@ -9,7 +8,15 @@
                       { "stop_fines"  : null }
                     ]
             }
+    },
+    "hold_request.shelf_expires_soon" : {
+        "context_org": "pickup_lib",
+        "filter": {
+            "shelf_expire_time": {"!=": null},
+            "capture_time": {"!=": null},
+            "current_copy": {"!=": null},
+            "shelf_time": {"!=": null},
+            "cancel_time": null
+        }
     }
-
 }
-
index 8d3a3b4..8e18b2b 100644 (file)
@@ -51,7 +51,7 @@ CREATE TABLE config.upgrade_log (
     install_date    TIMESTAMP WITH TIME ZONE NOT NULL DEFAULT NOW()
 );
 
-INSERT INTO config.upgrade_log (version) VALUES ('0078'); -- berick
+INSERT INTO config.upgrade_log (version) VALUES ('0079'); -- senator
 
 CREATE TABLE config.bib_source (
        id              SERIAL  PRIMARY KEY,
index c4da7cf..579d2e0 100644 (file)
@@ -2113,12 +2113,77 @@ The item(s) you requested are available for pickup from the Library.
 
 $$);
 
+
+INSERT INTO action_trigger.hook (
+        key,
+        core_type,
+        description,
+        passive
+    ) VALUES (
+        'hold_request.shelf_expires_soon',
+        'ahr',
+        'A hold on the shelf will expire there soon.',
+        TRUE
+    );
+
 INSERT INTO action_trigger.environment (event_def, path) VALUES
     (5, 'current_copy.call_number.record.simple_record'),
     (5, 'usr'),
     (5, 'pickup_lib.billing_address');
 
 
+INSERT INTO action_trigger.event_definition (
+        id,
+        active,
+        owner,
+        name,
+        hook,
+        validator,
+        reactor,
+        delay,
+        delay_field,
+        group_field,
+        template
+    ) VALUES (
+        7,
+        FALSE,
+        1,
+        'Hold Expires from Shelf Soon',
+        'hold_request.shelf_expires_soon',
+        'HoldIsAvailable',
+        'SendEmail',
+        '- 1 DAY',
+        'shelf_expire_time',
+        'usr',
+$$
+[%- USE date -%]
+[%- user = target.0.usr -%]
+To: [%- params.recipient_email || user.email %]
+From: [%- params.sender_email || default_sender %]
+Subject: Hold Available Notification
+
+Dear [% user.family_name %], [% user.first_given_name %]
+You requested holds on the following item(s), which are available for
+pickup, but these holds will soon expire.
+
+[% FOR hold IN target %]
+    [%- data = helpers.get_copy_bib_basics(hold.current_copy.id) -%]
+    Title: [% data.title %]
+    Author: [% data.author %]
+    Library: [% hold.pickup_lib.name %]
+[% END %]
+$$
+);
+
+
+INSERT INTO action_trigger.environment (
+        event_def,
+        path
+    ) VALUES
+    ( 7, 'current_copy'),
+    ( 7, 'pickup_lib.billing_address'),
+    ( 7, 'usr');
+
 SELECT SETVAL('action_trigger.event_definition_id_seq'::TEXT, 100);
 
 -- Org Unit Settings for configuring org unit weights and org unit max-loops for hold targeting
@@ -2195,6 +2260,8 @@ INSERT INTO action_trigger.hook (key,core_type,description) VALUES (
     'A hold is cancelled by the patron'
 );
 
+
+
 -- hold targeter skip me
 INSERT INTO config.org_unit_setting_type (name, label, description, datatype) VALUES (
     'circ.holds.target_skip_me',
diff --git a/Open-ILS/src/sql/Pg/upgrade/0079.data.hold_request.shelf_expires_soon.sql b/Open-ILS/src/sql/Pg/upgrade/0079.data.hold_request.shelf_expires_soon.sql
new file mode 100644 (file)
index 0000000..c45cea1
--- /dev/null
@@ -0,0 +1,68 @@
+BEGIN;
+
+INSERT INTO config.upgrade_log (version) VALUES ('0079'); -- senator
+
+INSERT INTO action_trigger.hook (
+        key,
+        core_type,
+        description,
+        passive
+    ) VALUES (
+        'hold_request.shelf_expires_soon',
+        'ahr',
+        'A hold on the shelf will expire there soon.',
+        TRUE
+    );
+
+INSERT INTO action_trigger.event_definition (
+        id,
+        active,
+        owner,
+        name,
+        hook,
+        validator,
+        reactor,
+        delay,
+        delay_field,
+        group_field,
+        template
+    ) VALUES (
+        7,
+        FALSE,
+        1,
+        'Hold Expires from Shelf Soon',
+        'hold_request.shelf_expires_soon',
+        'HoldIsAvailable',
+        'SendEmail',
+        '- 1 DAY',
+        'shelf_expire_time',
+        'usr',
+$$
+[%- USE date -%]
+[%- user = target.0.usr -%]
+To: [%- params.recipient_email || user.email %]
+From: [%- params.sender_email || default_sender %]
+Subject: Hold Available Notification
+
+Dear [% user.family_name %], [% user.first_given_name %]
+You requested holds on the following item(s), which are available for
+pickup, but these holds will soon expire.
+
+[% FOR hold IN target %]
+    [%- data = helpers.get_copy_bib_basics(hold.current_copy.id) -%]
+    Title: [% data.title %]
+    Author: [% data.author %]
+    Library: [% hold.pickup_lib.name %]
+[% END %]
+$$
+    );
+
+INSERT INTO action_trigger.environment (
+        event_def,
+        path
+    ) VALUES
+    ( 7, 'current_copy'),
+    ( 7, 'pickup_lib.billing_address'),
+    ( 7, 'usr');
+
+COMMIT;