[open-ils-commits] r15602 - in trunk/Open-ILS/src: perlmods/OpenILS/Application/Trigger/Validator perlmods/OpenILS/Application/Trigger/Validator/Acq sql/Pg sql/Pg/upgrade support-scripts/test-scripts (phasefx)
svn at svn.open-ils.org
svn at svn.open-ils.org
Fri Feb 19 15:56:44 EST 2010
Author: phasefx
Date: 2010-02-19 15:56:38 -0500 (Fri, 19 Feb 2010)
New Revision: 15602
Added:
trunk/Open-ILS/src/perlmods/OpenILS/Application/Trigger/Validator/Acq/
trunk/Open-ILS/src/perlmods/OpenILS/Application/Trigger/Validator/Acq/UserRequestCancelled.pm
trunk/Open-ILS/src/perlmods/OpenILS/Application/Trigger/Validator/Acq/UserRequestOrdered.pm
trunk/Open-ILS/src/perlmods/OpenILS/Application/Trigger/Validator/Acq/UserRequestReceived.pm
trunk/Open-ILS/src/sql/Pg/upgrade/0165.data.acq.patron_requests.sql
trunk/Open-ILS/src/support-scripts/test-scripts/print_aur.pl
Modified:
trunk/Open-ILS/src/perlmods/OpenILS/Application/Trigger/Validator/Acq.pm
trunk/Open-ILS/src/sql/Pg/002.schema.config.sql
Log:
email A/T templates for Acquisition User Requests, supporting ML tweaks, and testing utility
Added: trunk/Open-ILS/src/perlmods/OpenILS/Application/Trigger/Validator/Acq/UserRequestCancelled.pm
===================================================================
--- trunk/Open-ILS/src/perlmods/OpenILS/Application/Trigger/Validator/Acq/UserRequestCancelled.pm (rev 0)
+++ trunk/Open-ILS/src/perlmods/OpenILS/Application/Trigger/Validator/Acq/UserRequestCancelled.pm 2010-02-19 20:56:38 UTC (rev 15602)
@@ -0,0 +1,12 @@
+package OpenILS::Application::Trigger::Validator::Acq::UserRequestCancelled;
+use strict; use warnings;
+use OpenSRF::Utils::Logger qw/:logger/;
+use OpenILS::Application::Trigger::Validator::Acq;
+
+sub handler {
+ my $self = shift;
+ my $env = shift;
+ return OpenILS::Application::Trigger::Validator::Acq::get_lineitem_from_req($self, $env)->state eq 'cancelled';
+}
+
+1;
Added: trunk/Open-ILS/src/perlmods/OpenILS/Application/Trigger/Validator/Acq/UserRequestOrdered.pm
===================================================================
--- trunk/Open-ILS/src/perlmods/OpenILS/Application/Trigger/Validator/Acq/UserRequestOrdered.pm (rev 0)
+++ trunk/Open-ILS/src/perlmods/OpenILS/Application/Trigger/Validator/Acq/UserRequestOrdered.pm 2010-02-19 20:56:38 UTC (rev 15602)
@@ -0,0 +1,12 @@
+package OpenILS::Application::Trigger::Validator::Acq::UserRequestOrdered;
+use strict; use warnings;
+use OpenSRF::Utils::Logger qw/:logger/;
+use OpenILS::Application::Trigger::Validator::Acq;
+
+sub handler {
+ my $self = shift;
+ my $env = shift;
+ return OpenILS::Application::Trigger::Validator::Acq::get_lineitem_from_req($self, $env)->state eq 'on-order';
+}
+
+1;
Added: trunk/Open-ILS/src/perlmods/OpenILS/Application/Trigger/Validator/Acq/UserRequestReceived.pm
===================================================================
--- trunk/Open-ILS/src/perlmods/OpenILS/Application/Trigger/Validator/Acq/UserRequestReceived.pm (rev 0)
+++ trunk/Open-ILS/src/perlmods/OpenILS/Application/Trigger/Validator/Acq/UserRequestReceived.pm 2010-02-19 20:56:38 UTC (rev 15602)
@@ -0,0 +1,12 @@
+package OpenILS::Application::Trigger::Validator::Acq::UserRequestReceived;
+use strict; use warnings;
+use OpenSRF::Utils::Logger qw/:logger/;
+use OpenILS::Application::Trigger::Validator::Acq;
+
+sub handler {
+ my $self = shift;
+ my $env = shift;
+ return OpenILS::Application::Trigger::Validator::Acq::get_lineitem_from_req($self, $env)->state eq 'received';
+}
+
+1;
Modified: trunk/Open-ILS/src/perlmods/OpenILS/Application/Trigger/Validator/Acq.pm
===================================================================
--- trunk/Open-ILS/src/perlmods/OpenILS/Application/Trigger/Validator/Acq.pm 2010-02-19 20:11:48 UTC (rev 15601)
+++ trunk/Open-ILS/src/perlmods/OpenILS/Application/Trigger/Validator/Acq.pm 2010-02-19 20:56:38 UTC (rev 15602)
@@ -2,24 +2,6 @@
use strict; use warnings;
use OpenSRF::Utils::Logger qw/:logger/;
-sub UserRequestOrdered {
- my $self = shift;
- my $env = shift;
- return get_lineitem_from_req($self, $env)->state eq 'on-order';
-}
-
-sub UserRequestReceived {
- my $self = shift;
- my $env = shift;
- return get_lineitem_from_req($self, $env)->state eq 'received';
-}
-
-sub UserRequestCancelled {
- my $self = shift;
- my $env = shift;
- return get_lineitem_from_req($self, $env)->state eq 'cancelled';
-}
-
sub get_lineitem_from_req {
my($self, $env) = @_;
my $req = $env->{target};
Modified: trunk/Open-ILS/src/sql/Pg/002.schema.config.sql
===================================================================
--- trunk/Open-ILS/src/sql/Pg/002.schema.config.sql 2010-02-19 20:11:48 UTC (rev 15601)
+++ trunk/Open-ILS/src/sql/Pg/002.schema.config.sql 2010-02-19 20:56:38 UTC (rev 15602)
@@ -51,7 +51,7 @@
install_date TIMESTAMP WITH TIME ZONE NOT NULL DEFAULT NOW()
);
-INSERT INTO config.upgrade_log (version) VALUES ('0164'); -- Galen Charlton
+INSERT INTO config.upgrade_log (version) VALUES ('0165'); -- phasefx
CREATE TABLE config.bib_source (
id SERIAL PRIMARY KEY,
Added: trunk/Open-ILS/src/sql/Pg/upgrade/0165.data.acq.patron_requests.sql
===================================================================
--- trunk/Open-ILS/src/sql/Pg/upgrade/0165.data.acq.patron_requests.sql (rev 0)
+++ trunk/Open-ILS/src/sql/Pg/upgrade/0165.data.acq.patron_requests.sql 2010-02-19 20:56:38 UTC (rev 15602)
@@ -0,0 +1,169 @@
+BEGIN;
+
+INSERT INTO config.upgrade_log (version) VALUES ('0165'); -- phasefx
+
+INSERT INTO action_trigger.hook (
+ key,
+ core_type,
+ description,
+ passive
+ ) VALUES (
+ 'aur.ordered',
+ 'aur',
+ 'A patron acquisition request has been marked On-Order.',
+ TRUE
+ ), (
+ 'aur.received',
+ 'aur',
+ 'A patron acquisition request has been marked Received.',
+ TRUE
+ ), (
+ 'aur.cancelled',
+ 'aur',
+ 'A patron acquisition request has been marked Cancelled.',
+ TRUE
+ );
+
+INSERT INTO action_trigger.validator (module,description) VALUES (
+ 'Acq::UserRequestOrdered',
+ 'Tests to see if the corresponding Line Item has a state of "on-order".'
+ ), (
+ 'Acq::UserRequestReceived',
+ 'Tests to see if the corresponding Line Item has a state of "received".'
+ ), (
+ 'Acq::UserRequestCancelled',
+ 'Tests to see if the corresponding Line Item has a state of "cancelled".'
+ );
+
+INSERT INTO action_trigger.event_definition (
+ id,
+ active,
+ owner,
+ name,
+ hook,
+ validator,
+ reactor,
+ template
+ ) VALUES (
+ 15,
+ FALSE,
+ 1,
+ 'Email Notice: Patron Acquisition Request marked On-Order.',
+ 'aur.ordered',
+ 'Acq::UserRequestOrdered',
+ 'SendEmail',
+$$
+[%- USE date -%]
+[%- SET li = target.lineitem; -%]
+[%- SET user = target.usr -%]
+[%- SET title = helpers.get_li_attr("title", "", li.attributes) %]
+[%- SET author = helpers.get_li_attr("author", "", li.attributes) %]
+[%- SET edition = helpers.get_li_attr("edition", "", li.attributes) %]
+[%- SET isbn = helpers.get_li_attr("isbn", "", li.attributes) %]
+[%- SET publisher = helpers.get_li_attr("publisher", "", li.attributes) -%]
+[%- SET pubdate = helpers.get_li_attr("pubdate", "", li.attributes) -%]
+
+To: [%- params.recipient_email || user.email %]
+From: [%- params.sender_email || default_sender %]
+Subject: Acquisition Request Notification
+
+Dear [% user.family_name %], [% user.first_given_name %]
+Our records indicate the following acquisition request has been placed on order.
+
+Title: [% title %]
+[% IF author %]Author: [% author %][% END %]
+[% IF edition %]Edition: [% edition %][% END %]
+[% IF isbn %]ISBN: [% isbn %][% END %]
+[% IF publisher %]Publisher: [% publisher %][% END %]
+[% IF pubdate %]Publication Date: [% pubdate %][% END %]
+Lineitem ID: [% li.id %]
+$$
+ ), (
+ 16,
+ FALSE,
+ 1,
+ 'Email Notice: Patron Acquisition Request marked Received.',
+ 'aur.received',
+ 'Acq::UserRequestReceived',
+ 'SendEmail',
+$$
+[%- USE date -%]
+[%- SET li = target.lineitem; -%]
+[%- SET user = target.usr -%]
+[%- SET title = helpers.get_li_attr("title", "", li.attributes) %]
+[%- SET author = helpers.get_li_attr("author", "", li.attributes) %]
+[%- SET edition = helpers.get_li_attr("edition", "", li.attributes) %]
+[%- SET isbn = helpers.get_li_attr("isbn", "", li.attributes) %]
+[%- SET publisher = helpers.get_li_attr("publisher", "", li.attributes) -%]
+[%- SET pubdate = helpers.get_li_attr("pubdate", "", li.attributes) -%]
+
+To: [%- params.recipient_email || user.email %]
+From: [%- params.sender_email || default_sender %]
+Subject: Acquisition Request Notification
+
+Dear [% user.family_name %], [% user.first_given_name %]
+Our records indicate the materials for the following acquisition request have been received.
+
+Title: [% title %]
+[% IF author %]Author: [% author %][% END %]
+[% IF edition %]Edition: [% edition %][% END %]
+[% IF isbn %]ISBN: [% isbn %][% END %]
+[% IF publisher %]Publisher: [% publisher %][% END %]
+[% IF pubdate %]Publication Date: [% pubdate %][% END %]
+Lineitem ID: [% li.id %]
+$$
+ ), (
+ 17,
+ FALSE,
+ 1,
+ 'Email Notice: Patron Acquisition Request marked Cancelled.',
+ 'aur.cancelled',
+ 'Acq::UserRequestCancelled',
+ 'SendEmail',
+$$
+[%- USE date -%]
+[%- SET li = target.lineitem; -%]
+[%- SET user = target.usr -%]
+[%- SET title = helpers.get_li_attr("title", "", li.attributes) %]
+[%- SET author = helpers.get_li_attr("author", "", li.attributes) %]
+[%- SET edition = helpers.get_li_attr("edition", "", li.attributes) %]
+[%- SET isbn = helpers.get_li_attr("isbn", "", li.attributes) %]
+[%- SET publisher = helpers.get_li_attr("publisher", "", li.attributes) -%]
+[%- SET pubdate = helpers.get_li_attr("pubdate", "", li.attributes) -%]
+
+To: [%- params.recipient_email || user.email %]
+From: [%- params.sender_email || default_sender %]
+Subject: Acquisition Request Notification
+
+Dear [% user.family_name %], [% user.first_given_name %]
+Our records indicate the following acquisition request has been cancelled.
+
+Title: [% title %]
+[% IF author %]Author: [% author %][% END %]
+[% IF edition %]Edition: [% edition %][% END %]
+[% IF isbn %]ISBN: [% isbn %][% END %]
+[% IF publisher %]Publisher: [% publisher %][% END %]
+[% IF pubdate %]Publication Date: [% pubdate %][% END %]
+Lineitem ID: [% li.id %]
+$$
+ );
+
+INSERT INTO action_trigger.environment (
+ event_def,
+ path
+ ) VALUES
+ ( 15, 'lineitem' ),
+ ( 15, 'lineitem.attributes' ),
+ ( 15, 'usr' ),
+
+ ( 16, 'lineitem' ),
+ ( 16, 'lineitem.attributes' ),
+ ( 16, 'usr' ),
+
+ ( 17, 'lineitem' ),
+ ( 17, 'lineitem.attributes' ),
+ ( 17, 'usr' )
+ ;
+
+COMMIT;
+
Added: trunk/Open-ILS/src/support-scripts/test-scripts/print_aur.pl
===================================================================
--- trunk/Open-ILS/src/support-scripts/test-scripts/print_aur.pl (rev 0)
+++ trunk/Open-ILS/src/support-scripts/test-scripts/print_aur.pl 2010-02-19 20:56:38 UTC (rev 15602)
@@ -0,0 +1,56 @@
+#!/usr/bin/perl
+
+#----------------------------------------------------------------
+# Print AUR
+#----------------------------------------------------------------
+
+require '../oils_header.pl';
+use vars qw/$apputils/;
+use strict;
+use Data::Dumper;
+my $config = shift;
+my $username = shift || 'admin';
+my $password = shift || 'open-ils';
+my $aur_id = shift;
+my $hook = shift || 'aur.ordered';
+
+osrf_connect($config);
+oils_login($username, $password);
+my $e = OpenILS::Utils::CStoreEditor->new;
+
+my $aur = $e->retrieve_acq_user_request($aur_id) or oils_event_die($e->event);
+my $orgs = $apputils->get_org_ancestors($aur->pickup_lib);
+my $defs = $e->search_action_trigger_event_definition({hook => $hook, owner => $orgs});
+$defs = [sort { $a->id cmp $b->id } @$defs ]; # this is a brittle hack, but.. meh
+my $def = pop @$defs;
+print "using def " . $def->id . " at org_unit " . $def->owner . "\n";
+
+die "No event_definition found with hook $hook\n" unless $def;
+
+my $event_id = $apputils->simplereq(
+ 'open-ils.trigger',
+ 'open-ils.trigger.event.autocreate.by_definition.include_inactive',
+ $def->id, $aur, $aur->pickup_lib);
+
+
+my $result = $apputils->simplereq(
+ 'open-ils.trigger',
+ 'open-ils.trigger.event.fire', $event_id);
+
+
+print "Event state is " . $result->{event}->state . "\n";
+
+my $event = $e->retrieve_action_trigger_event(
+ [
+ $event_id,
+ {flesh => 1, flesh_fields => {atev => ['template_output', 'error_output']}}
+ ]
+);
+
+if($event->template_output) {
+ print $event->template_output->data . "\n";
+}
+if($event->error_output) {
+ print $event->error_output->data . "\n";
+}
+
Property changes on: trunk/Open-ILS/src/support-scripts/test-scripts/print_aur.pl
___________________________________________________________________
Name: svn:executable
+ *
More information about the open-ils-commits
mailing list