From f3d2d070e8ca3a8b12a820489ee6caff8dc1c7e9 Mon Sep 17 00:00:00 2001 From: Galen Charlton Date: Wed, 3 Aug 2016 15:37:39 -0400 Subject: [PATCH] LP#1356477: create new staging table for user settings This patch creates a new table called staging.setting_stage that allows for storing user settings when a patron uses (for example) the self-registration page. Signed-off-by: Galen Charlton Signed-off-by: Mike Rylander --- Open-ILS/examples/fm_IDL.xml | 11 +++++++++++ .../perlmods/lib/OpenILS/Application/Actor/Stage.pm | 20 +++++++++++++++++--- Open-ILS/src/sql/Pg/015.schema.staging.sql | 9 +++++++++ .../Pg/upgrade/YYYY.schema.staging-user-setting.sql | 12 ++++++++++++ 4 files changed, 49 insertions(+), 3 deletions(-) create mode 100644 Open-ILS/src/sql/Pg/upgrade/YYYY.schema.staging-user-setting.sql diff --git a/Open-ILS/examples/fm_IDL.xml b/Open-ILS/examples/fm_IDL.xml index 65dc4db260..485e4c693f 100644 --- a/Open-ILS/examples/fm_IDL.xml +++ b/Open-ILS/examples/fm_IDL.xml @@ -9608,6 +9608,17 @@ SELECT usr, + + + + + + + + + + + diff --git a/Open-ILS/src/perlmods/lib/OpenILS/Application/Actor/Stage.pm b/Open-ILS/src/perlmods/lib/OpenILS/Application/Actor/Stage.pm index 8f094b7204..c8be3212c2 100644 --- a/Open-ILS/src/perlmods/lib/OpenILS/Application/Actor/Stage.pm +++ b/Open-ILS/src/perlmods/lib/OpenILS/Application/Actor/Stage.pm @@ -13,7 +13,8 @@ __PACKAGE__->register_method ( api_name => 'open-ils.actor.user.stage.create', signature => { desc => q/ - Creates a new pending user account including addresses and statcats. + Creates a new pending user account including addresses, statcats, and + settings. Users are added to staging tables pending staff review. /, params => [ @@ -21,6 +22,7 @@ __PACKAGE__->register_method ( {desc => 'Mailing address. Optional', type => 'object', class => 'stgma'}, {desc => 'Billing address. Optional', type => 'object', class => 'stgba'}, {desc => 'Statcats. Optional. This is an array of "stgsc" objects', type => 'array'}, + {desc => 'Settings. Optional. This is an array of "stgs" objects', type => 'array'}, ], return => { desc => 'username on success, Event on error', @@ -31,7 +33,7 @@ __PACKAGE__->register_method ( ); sub create_user_stage { - my($self, $conn, $user, $mail_addr, $bill_addr, $statcats) = @_; # more? + my($self, $conn, $user, $mail_addr, $bill_addr, $statcats, $settings) = @_; # more? return OpenILS::Event->new('BAD_PARAMS') unless $user; return 0 unless $U->ou_ancestor_setting_value($user->home_ou, 'opac.allow_pending_user'); @@ -64,6 +66,13 @@ sub create_user_stage { } } + if($settings) { + foreach (@$settings) { + $_->usrname($uname); + $e->create_staging_setting_stage($_) or return $e->die_event; + } + } + $e->commit; $conn->respond_complete($uname); @@ -111,7 +120,8 @@ sub flesh_user_stage { billing_addresses => $e->search_staging_billing_address_stage({usrname => $user->usrname}), mailing_addresses => $e->search_staging_mailing_address_stage({usrname => $user->usrname}), cards => $e->search_staging_card_stage({usrname => $user->usrname}), - statcats => $e->search_staging_statcat_stage({usrname => $user->usrname}) + statcats => $e->search_staging_statcat_stage({usrname => $user->usrname}), + settings => $e->search_staging_setting_stage({usrname => $user->usrname}), }; } @@ -171,6 +181,10 @@ sub delete_user_stage { $e->delete_staging_statcat_stage($statcat) or return $e->die_event; } + for my $setting (@{$data->{settings}}) { + $e->delete_staging_setting_stage($setting) or return $e->die_event; + } + $e->commit; return 1; } diff --git a/Open-ILS/src/sql/Pg/015.schema.staging.sql b/Open-ILS/src/sql/Pg/015.schema.staging.sql index 3f558e1ae5..4dfc3ee98a 100644 --- a/Open-ILS/src/sql/Pg/015.schema.staging.sql +++ b/Open-ILS/src/sql/Pg/015.schema.staging.sql @@ -60,6 +60,15 @@ CREATE TABLE staging.statcat_stage ( complete BOOL DEFAULT FALSE ); +CREATE TABLE staging.setting_stage ( + row_id BIGSERIAL PRIMARY KEY, + row_date TIMESTAMP WITH TIME ZONE DEFAULT NOW(), + usrname TEXT NOT NULL, + setting TEXT NOT NULL, + value TEXT NOT NULL, + complete BOOL DEFAULT FALSE +); + -- stored procedure for deleting expired pending patrons CREATE OR REPLACE FUNCTION staging.purge_pending_users() RETURNS VOID AS $$ DECLARE diff --git a/Open-ILS/src/sql/Pg/upgrade/YYYY.schema.staging-user-setting.sql b/Open-ILS/src/sql/Pg/upgrade/YYYY.schema.staging-user-setting.sql new file mode 100644 index 0000000000..55908ad8a6 --- /dev/null +++ b/Open-ILS/src/sql/Pg/upgrade/YYYY.schema.staging-user-setting.sql @@ -0,0 +1,12 @@ +BEGIN; + +CREATE TABLE staging.setting_stage ( + row_id BIGSERIAL PRIMARY KEY, + row_date TIMESTAMP WITH TIME ZONE DEFAULT NOW(), + usrname TEXT NOT NULL, + setting TEXT NOT NULL, + value TEXT NOT NULL, + complete BOOL DEFAULT FALSE +); + +COMMIT; -- 2.11.0