LP1207396 DB / IDL for patron self-reg
authorBill Erickson <berick@esilibrary.com>
Thu, 1 Aug 2013 17:30:52 +0000 (13:30 -0400)
committerBill Erickson <berick@esilibrary.com>
Mon, 26 Aug 2013 13:32:53 +0000 (09:32 -0400)
Updating pending addr tables to track requesting user and address county.

Adding org settings:

* opac.allow_pending_user -- allow self-registration
* opac.pending_user_expire_interval - delete pending user interval
* ui.patron.edit.aua.county.require - indicate if county is required

Signed-off-by: Bill Erickson <berick@esilibrary.com>
Signed-off-by: Dan Wells <dbw2@calvin.edu>
Open-ILS/examples/fm_IDL.xml
Open-ILS/src/sql/Pg/015.schema.staging.sql
Open-ILS/src/sql/Pg/950.data.seed-values.sql
Open-ILS/src/sql/Pg/upgrade/XXXX.schema.patron-self-reg.sql [new file with mode: 0644]

index f1078cc..fed7a1a 100644 (file)
@@ -8763,7 +8763,11 @@ SELECT  usr,
             <field reporter:label="Home Library" name="home_ou" reporter:datatype="int"/>
             <field reporter:label="Date of Birth" name="dob" reporter:datatype="text"/>
             <field reporter:label="Complete" name="complete" reporter:datatype="bool"/>
+            <field reporter:label="Requesting User" name="requesting_usr" reporter:datatype="link"/>
         </fields>
+               <links>
+                       <link field="requesting_usr" reltype="has_a" key="id" map="" class="au"/>
+               </links>
     </class>
 
     <class id="stgc" controller="open-ils.cstore open-ils.pcrud" oils_obj:fieldmapper="staging::card_stage" oils_persist:tablename="staging.card_stage" reporter:label="Card Stage">
@@ -8784,6 +8788,7 @@ SELECT  usr,
             <field reporter:label="Street (1)" name="street1" reporter:datatype="text"/>
             <field reporter:label="Street (2)" name="street2" reporter:datatype="text"/>
             <field reporter:label="City" name="city" reporter:datatype="text"/>
+                       <field reporter:label="County" name="county"  reporter:datatype="text"/>
             <field reporter:label="State" name="state" reporter:datatype="text"/>
             <field reporter:label="Country" name="country" reporter:datatype="text"/>
             <field reporter:label="Postal Code" name="post_code" reporter:datatype="text"/>
@@ -8799,6 +8804,7 @@ SELECT  usr,
             <field reporter:label="Street (1)" name="street1" reporter:datatype="text"/>
             <field reporter:label="Street (2)" name="street2" reporter:datatype="text"/>
             <field reporter:label="City" name="city" reporter:datatype="text"/>
+                       <field reporter:label="County" name="county"  reporter:datatype="text"/>
             <field reporter:label="State" name="state" reporter:datatype="text"/>
             <field reporter:label="Country" name="country" reporter:datatype="text"/>
             <field reporter:label="Postal Code" name="post_code" reporter:datatype="text"/>
index 893650d..83bc697 100644 (file)
@@ -6,7 +6,7 @@ CREATE SCHEMA staging;
 
 CREATE TABLE staging.user_stage (
         row_id                  BIGSERIAL PRIMARY KEY,
-        row_date                            TIMESTAMP WITH TIME ZONE DEFAULT NOW(),
+        row_date                TIMESTAMP WITH TIME ZONE DEFAULT NOW(),
         usrname                 TEXT NOT NULL,
         profile                 TEXT,
         email                   TEXT,
@@ -19,7 +19,8 @@ CREATE TABLE staging.user_stage (
         evening_phone           TEXT,
         home_ou                 INT DEFAULT 2,
         dob                     TEXT,
-        complete                BOOL DEFAULT FALSE
+        complete                BOOL DEFAULT FALSE,
+        requesting_usr          INT REFERENCES actor.usr(id) ON DELETE SET NULL
 );
 
 CREATE TABLE staging.card_stage ( -- for new library barcodes
@@ -32,12 +33,13 @@ CREATE TABLE staging.card_stage ( -- for new library barcodes
 
 CREATE TABLE staging.mailing_address_stage (
         row_id          BIGSERIAL PRIMARY KEY,
-        row_date            TIMESTAMP WITH TIME ZONE DEFAULT NOW(),
+        row_date        TIMESTAMP WITH TIME ZONE DEFAULT NOW(),
         usrname         TEXT NOT NULL,  -- user's SIS barcode, for linking
         street1         TEXT,
         street2         TEXT,
         city            TEXT NOT NULL DEFAULT '',
-        state           TEXT    NOT NULL DEFAULT 'OK',
+        county          TEXT,
+        state           TEXT,
         country         TEXT NOT NULL DEFAULT 'US',
         post_code       TEXT NOT NULL,
         complete        BOOL DEFAULT FALSE
index 0c4d18e..199bf14 100644 (file)
@@ -12658,3 +12658,347 @@ VALUES (
     'bool'
 );
 
+INSERT INTO config.z3950_index_field_map 
+    (id, label, metabib_field, z3950_attr_type) VALUES 
+(1, oils_i18n_gettext(1, 'Title',   'czifm', 'label'), 5,  'title'),
+(2, oils_i18n_gettext(2, 'Author',  'czifm', 'label'), 8,  'author'),
+(3, oils_i18n_gettext(3, 'ISBN',    'czifm', 'label'), 18, 'isbn'),
+(4, oils_i18n_gettext(4, 'ISSN',    'czifm', 'label'), 19, 'issn'),
+(5, oils_i18n_gettext(5, 'LCCN',    'czifm', 'label'), 30, 'lccn');
+
+INSERT INTO config.z3950_index_field_map 
+    (id, label, record_attr, z3950_attr_type) VALUES 
+(6, oils_i18n_gettext(6, 'Pubdate',  'czifm', 'label'),'pubdate', 'pubdate'),
+(7, oils_i18n_gettext(7, 'Item Type', 'czifm', 'label'),'item_type', 'item_type');
+
+
+-- let's leave room for more stock mappings
+SELECT SETVAL('config.z3950_index_field_map_id_seq'::TEXT, 1000);
+
+INSERT INTO config.org_unit_setting_type
+    (name, grp, label, description, datatype)
+    VALUES (
+        'cat.z3950.batch.max_parallel',
+        'cat',
+        oils_i18n_gettext(
+            'cat.z3950.batch.max_parallel',
+            'Maximum Parallel Z39.50 Batch Searches',
+            'coust',
+            'label'
+        ),
+        oils_i18n_gettext(
+            'cat.z3950.batch.max_parallel',
+            'The maximum number of Z39.50 searches that can be in-flight at any given time when performing batch Z39.50 searches',
+            'coust',
+            'description'
+        ),
+        'integer'
+    );
+
+INSERT INTO config.org_unit_setting_type
+    (name, grp, label, description, datatype)
+    VALUES (
+        'cat.z3950.batch.max_results',
+        'cat',
+        oils_i18n_gettext(
+            'cat.z3950.batch.max_results',
+            'Maximum Z39.50 Batch Search Results',
+            'coust',
+            'label'
+        ),
+        oils_i18n_gettext(
+            'cat.z3950.batch.max_results',
+            'The maximum number of search results to retrieve and queue for each record + Z39 source during batch Z39.50 searches',
+            'coust',
+            'description'
+        ),
+        'integer'
+    );
+
+-- long overdue stuff...
+
+INSERT INTO config.org_unit_setting_type 
+    (name, grp, datatype, label, description) VALUES 
+(
+    'circ.longoverdue_immediately_available',
+    'circ', 'bool',
+    oils_i18n_gettext(
+        'circ.longoverdue_immediately_available',
+        'Long-Overdue Items Usable on Checkin',
+        'coust',
+        'label'
+    ),
+    oils_i18n_gettext(
+        'circ.longoverdue_immediately_available',
+        'Long-overdue items are usable on checkin instead of going "home" first',
+        'coust',
+        'description'
+    )
+), (
+    'circ.longoverdue_materials_processing_fee',
+    'finance', 'currency',
+    oils_i18n_gettext(
+        'circ.longoverdue_materials_processing_fee',
+        'Long-Overdue Materials Processing Fee',
+        'coust',
+        'label'
+    ),
+    oils_i18n_gettext(
+        'circ.longoverdue_materials_processing_fee',
+        'Long-Overdue Materials Processing Fee',
+        'coust',
+        'description'
+    )
+), (
+    'circ.max_accept_return_of_longoverdue',
+    'circ', 'interval',
+    oils_i18n_gettext(
+        'circ.max_accept_return_of_longoverdue',
+        'Long-Overdue Max Return Interval',
+        'coust',
+        'label'
+    ),
+    oils_i18n_gettext(
+        'circ.max_accept_return_of_longoverdue',
+        'Long-overdue check-in processing (voiding fees, re-instating ' ||
+            'overdues, etc.) will not take place for items that have been ' ||
+            'overdue for (or have last activity older than) this amount of time',
+        'coust',
+        'description'
+    )
+), (
+    'circ.restore_overdue_on_longoverdue_return',
+    'circ', 'bool',
+    oils_i18n_gettext(
+        'circ.restore_overdue_on_longoverdue_return',
+        'Restore Overdues on Long-Overdue Item Return',
+        'coust',
+        'label'
+    ),
+    oils_i18n_gettext(
+        'circ.restore_overdue_on_longoverdue_return',
+        'Restore Overdues on Long-Overdue Item Return',
+        'coust',
+        'description'
+    )
+), (
+    'circ.void_longoverdue_on_checkin',
+    'circ', 'bool',
+    oils_i18n_gettext(
+        'circ.void_longoverdue_on_checkin',
+        'Void Long-Overdue Item Billing When Returned',
+        'coust',
+        'label'
+    ),
+    oils_i18n_gettext(
+        'circ.void_longoverdue_on_checkin',
+        'Void Long-Overdue Item Billing When Returned',
+        'coust',
+        'description'
+    )
+), (
+    'circ.void_longoverdue_proc_fee_on_checkin',
+    'circ', 'bool',
+    oils_i18n_gettext(
+        'circ.void_longoverdue_proc_fee_on_checkin',
+        'Void Processing Fee on Long-Overdue Item Return',
+        'coust',
+        'label'
+    ),
+    oils_i18n_gettext(
+        'circ.void_longoverdue_proc_fee_on_checkin',
+        'Void Processing Fee on Long-Overdue Item Return',
+        'coust',
+        'description'
+    )
+), (
+    'circ.void_overdue_on_longoverdue',
+    'finance', 'bool',
+    oils_i18n_gettext(
+        'circ.void_overdue_on_longoverdue',
+        'Void Overdue Fines When Items are Marked Long-Overdue',
+        'coust',
+        'label'
+    ),
+    oils_i18n_gettext(
+        'circ.void_overdue_on_longoverdue',
+        'Void Overdue Fines When Items are Marked Long-Overdue',
+        'coust',
+        'description'
+    )
+), (
+    'circ.longoverdue.xact_open_on_zero',
+    'finance', 'bool',
+    oils_i18n_gettext(
+        'circ.longoverdue.xact_open_on_zero',
+        'Leave transaction open when long overdue balance equals zero',
+        'coust',
+        'label'
+    ),
+    oils_i18n_gettext(
+        'circ.longoverdue.xact_open_on_zero',
+        'Leave transaction open when long-overdue balance equals zero.  ' ||
+            'This leaves the lost copy on the patron record when it is paid',
+        'coust',
+        'description'
+    )
+), (
+    'circ.longoverdue.use_last_activity_date_on_return',
+    'circ', 'bool',
+    oils_i18n_gettext(
+        'circ.longoverdue.use_last_activity_date_on_return',
+        'Long-Overdue Check-In Interval Uses Last Activity Date',
+        'coust',
+        'label'
+    ),
+    oils_i18n_gettext(
+        'circ.longoverdue.use_last_activity_date_on_return',
+        'Use the long-overdue last-activity date instead of the due_date to ' ||
+            'determine whether the item has been checked out too long to ' ||
+            'perform long-overdue check-in processing.  If set, the system ' ||
+            'will first check the last payment time, followed by the last ' ||
+            'billing time, followed by the due date.  See also ' ||
+            'circ.max_accept_return_of_longoverdue',
+        'coust',
+        'description'
+    )
+);
+
+-- mark long-overdue reactor
+
+INSERT INTO action_trigger.reactor (module, description) VALUES
+(   'MarkItemLongOverdue',
+    oils_i18n_gettext(
+        'MarkItemLongOverdue',
+        'Marks a circulating item as long-overdue and applies configured ' ||
+        'penalties.  Also creates events for the longoverdue.auto hook',
+        'atreact',
+        'description'
+    )
+);
+
+INSERT INTO action_trigger.validator (module, description) VALUES (
+    'PatronNotInCollections', 
+    'Event is valid if the linked patron is not in collections processing ' ||
+        'at the context org unit'
+);
+
+INSERT INTO action_trigger.event_definition 
+    (id, active, owner, name, hook, validator, reactor, delay, delay_field) 
+VALUES (
+    49, FALSE, 1, '6 Month Overdue Mark Long-Overdue', 
+    'checkout.due', 'PatronNotInCollections', 
+    'MarkItemLongOverdue', '6 months', 'due_date'
+);
+
+INSERT INTO action_trigger.event_params (event_def, param, value) VALUES
+    (49, 'editor', '''1''');
+
+-- new longoverdue and longervdue.auto hook.
+
+INSERT INTO action_trigger.hook (key,core_type,description) VALUES (
+    'longoverdue',
+    'circ',
+    'Circulating Item marked long-overdue'
+);
+
+INSERT INTO action_trigger.hook (key,core_type,description) VALUES (
+    'longoverdue.auto',
+    'circ',
+    'Circulating Item automatically marked long-overdue'
+);
+
+-- sample longoverdue.auto notification reactor
+
+INSERT INTO action_trigger.event_definition 
+    (id, active, owner, name, hook, validator, reactor, group_field, template) 
+    VALUES (
+        50, FALSE, 1, '6 Month Long Overdue Notice', 
+        'longoverdue.auto', 'NOOP_True', 'SendEmail', 'usr',
+$$
+[%- USE date -%]
+[%- user = target.0.usr -%]
+To: [%- params.recipient_email || user.email %]
+From: [%- params.sender_email || default_sender %]
+Subject: Overdue Items Marked Long Overdue
+
+Dear [% user.family_name %], [% user.first_given_name %]
+The following items are 6 months overdue and have been marked Long Overdue.
+
+[% FOR circ IN target %]
+    [%- copy_details = helpers.get_copy_bib_basics(circ.target_copy.id) -%]
+    Title: [% copy_details.title %], by [% copy_details.author %]
+    Call Number: [% circ.target_copy.call_number.label %]
+    Shelving Location: [% circ.target_copy.location.name %]
+    Barcode: [% circ.target_copy.barcode %]
+    Due: [% date.format(helpers.format_date(circ.due_date), '%Y-%m-%d') %]
+    Item Cost: [% helpers.get_copy_price(circ.target_copy) %]
+    Total Owed For Transaction: [% circ.billable_transaction.summary.balance_owed %]
+    Library: [% circ.circ_lib.name %]
+
+[% END %]
+$$);
+
+-- ENV for above
+
+INSERT INTO action_trigger.environment (event_def, path) VALUES 
+    (50, 'target_copy.call_number'),
+    (50, 'usr'),
+    (50, 'billable_transaction.summary'),
+    (50, 'circ_lib.billing_address'),
+    (50, 'target_copy.location');
+
+-- OUS's for patron self-reg
+INSERT INTO config.org_unit_setting_type
+    (name, grp, datatype, label, description)
+VALUES (
+    'opac.allow_pending_user',
+    'opac',
+    'bool',
+    oils_i18n_gettext(
+        'opac.allow_pending_user',
+        'Allow Patron Self-Registration',
+        'coust',
+        'label'
+    ),
+    oils_i18n_gettext(
+        'opac.allow_pending_user',
+        'Allow patrons to self-register, creating pending user accounts',
+        'coust',
+        'description'
+    )
+), (
+    'opac.pending_user_expire_interval',
+    'opac',
+    'interval',
+    oils_i18n_gettext(
+        'opac.pending_user_expire_interval',
+        'Patron Self-Reg. Expire Interval',
+        'coust',
+        'label'
+    ),
+    oils_i18n_gettext(
+        'opac.pending_user_expire_interval',
+        'If set, this is the amount of time a pending user account will ' ||
+        'be allowed to sit in the database.  After this time, the pending ' ||
+        'user information will be purged',
+        'coust',
+        'description'
+    )
+), (
+    'ui.patron.edit.aua.county.show',
+    'gui',
+    'bool',
+    oils_i18n_gettext(
+        'ui.patron.edit.aua.county.require',
+        'Show count field on patron registration',
+        'coust',
+        'label'
+    ),
+    oils_i18n_gettext(
+        'ui.patron.edit.aua.county.require',
+        'The county field will be shown on the patron registration screen',
+        'coust',
+        'description'
+    )
+);
diff --git a/Open-ILS/src/sql/Pg/upgrade/XXXX.schema.patron-self-reg.sql b/Open-ILS/src/sql/Pg/upgrade/XXXX.schema.patron-self-reg.sql
new file mode 100644 (file)
index 0000000..9f6a574
--- /dev/null
@@ -0,0 +1,75 @@
+
+BEGIN;
+
+-- Track the requesting user
+ALTER TABLE staging.user_stage
+    ADD COLUMN requesting_usr INTEGER 
+        REFERENCES actor.usr(id) ON DELETE SET NULL;
+
+-- add county column to staged address tables and 
+-- drop state requirement to match actor.usr_address
+ALTER TABLE staging.mailing_address_stage 
+    ADD COLUMN county TEXT,
+    ALTER COLUMN state DROP DEFAULT,
+    ALTER COLUMN state DROP NOT NULL;
+
+ALTER TABLE staging.billing_address_stage 
+    ADD COLUMN county TEXT,
+    ALTER COLUMN state DROP DEFAULT,
+    ALTER COLUMN state DROP NOT NULL;
+
+INSERT INTO config.org_unit_setting_type
+    (name, grp, datatype, label, description)
+VALUES (
+    'opac.allow_pending_user',
+    'opac',
+    'bool',
+    oils_i18n_gettext(
+        'opac.allow_pending_user',
+        'Allow Patron Self-Registration',
+        'coust',
+        'label'
+    ),
+    oils_i18n_gettext(
+        'opac.allow_pending_user',
+        'Allow patrons to self-register, creating pending user accounts',
+        'coust',
+        'description'
+    )
+), (
+    'opac.pending_user_expire_interval',
+    'opac',
+    'interval',
+    oils_i18n_gettext(
+        'opac.pending_user_expire_interval',
+        'Patron Self-Reg. Expire Interval',
+        'coust',
+        'label'
+    ),
+    oils_i18n_gettext(
+        'opac.pending_user_expire_interval',
+        'If set, this is the amount of time a pending user account will ' ||
+        'be allowed to sit in the database.  After this time, the pending ' ||
+        'user information will be purged',
+        'coust',
+        'description'
+    )
+), (
+    'ui.patron.edit.aua.county.show',
+    'gui',
+    'bool',
+    oils_i18n_gettext(
+        'ui.patron.edit.aua.county.require',
+        'Show count field on patron registration',
+        'coust',
+        'label'
+    ),
+    oils_i18n_gettext(
+        'ui.patron.edit.aua.county.require',
+        'The county field will be shown on the patron registration screen',
+        'coust',
+        'description'
+    )
+);
+
+COMMIT;