From 7e3f7e6af1be85e8bd6730d9bef0adf15784a662 Mon Sep 17 00:00:00 2001 From: Kyle Huckins Date: Sun, 13 Mar 2022 05:05:55 +0000 Subject: [PATCH] lp1923057 Course Materials disassociate Rework - Adds a "Currently Associated" boolean and Removal time for course materials - When disassociating a course material, the time will still show up in the admin grid for course materials, marked as not currently associated. Signed-off-by: Kyle Huckins --- Open-ILS/examples/fm_IDL.xml | 2 ++ .../course-associate-material.component.html | 4 +++- .../src/perlmods/lib/OpenILS/Application/Courses.pm | 17 ++++++++++++++--- .../src/perlmods/lib/OpenILS/WWW/EGCatLoader/Course.pm | 2 +- Open-ILS/src/sql/Pg/040.schema.asset.sql | 2 ++ ...xx.schema.lp1923057-course-material-removal-time.sql | 8 ++++++++ 6 files changed, 30 insertions(+), 5 deletions(-) create mode 100644 Open-ILS/src/sql/Pg/upgrade/xxxx.schema.lp1923057-course-material-removal-time.sql diff --git a/Open-ILS/examples/fm_IDL.xml b/Open-ILS/examples/fm_IDL.xml index 671205919b..43d5ef866c 100644 --- a/Open-ILS/examples/fm_IDL.xml +++ b/Open-ILS/examples/fm_IDL.xml @@ -3318,10 +3318,12 @@ Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA + + diff --git a/Open-ILS/src/eg2/src/app/staff/admin/local/course-reserves/course-associate-material.component.html b/Open-ILS/src/eg2/src/app/staff/admin/local/course-reserves/course-associate-material.component.html index 4581028fa5..a0b149c867 100644 --- a/Open-ILS/src/eg2/src/app/staff/admin/local/course-reserves/course-associate-material.component.html +++ b/Open-ILS/src/eg2/src/app/staff/admin/local/course-reserves/course-associate-material.component.html @@ -219,7 +219,7 @@
- + @@ -239,8 +239,10 @@ + + diff --git a/Open-ILS/src/perlmods/lib/OpenILS/Application/Courses.pm b/Open-ILS/src/perlmods/lib/OpenILS/Application/Courses.pm index 6e7c7528d7..f31e644bcc 100644 --- a/Open-ILS/src/perlmods/lib/OpenILS/Application/Courses.pm +++ b/Open-ILS/src/perlmods/lib/OpenILS/Application/Courses.pm @@ -10,6 +10,12 @@ use base qw/OpenILS::Application/; use OpenILS::Utils::CStoreEditor qw/:funcs/; use OpenILS::Utils::Fieldmapper; use OpenILS::Application::AppUtils; + +use DateTime; +use DateTime::Format::ISO8601; + +use OpenILS::Utils::DateTime qw/:datetime/; + my $U = "OpenILS::Application::AppUtils"; use OpenSRF::Utils::Logger qw/$logger/; @@ -244,9 +250,14 @@ sub detach_material { } if ($acmcm->item) { _resetItemFields($e, $authtoken, $acmcm); - } + } + + my $removal_time = OpenILS::Utils::DateTime->clean_ISO8601(DateTime->now); + + $acmcm->removal_time($removal_time); + $acmcm->is_active('f'); - $e->delete_asset_course_module_course_materials($acmcm) or return $e->die_event; + $e->update_asset_course_module_course_materials($acmcm) or return $e->die_event; $e->commit; return 1; } @@ -265,7 +276,7 @@ sub _resetItemFields { if ($acmcm->original_location) { $acp->location($acmcm->original_location); } - $e->update_asset_copy($acmcm); + $e->update_asset_copy($acp); if ($acmcm->original_callnumber) { my $existing_acn = $e->retrieve_asset_call_number($acp->call_number); my $orig_acn = $e->retrieve_asset_call_number($acmcm->original_callnumber); diff --git a/Open-ILS/src/perlmods/lib/OpenILS/WWW/EGCatLoader/Course.pm b/Open-ILS/src/perlmods/lib/OpenILS/WWW/EGCatLoader/Course.pm index 260221f4d0..5caca93870 100644 --- a/Open-ILS/src/perlmods/lib/OpenILS/WWW/EGCatLoader/Course.pm +++ b/Open-ILS/src/perlmods/lib/OpenILS/WWW/EGCatLoader/Course.pm @@ -36,7 +36,7 @@ sub load_course { $ctx->{course_materials} = $U->simplereq( 'open-ils.courses', 'open-ils.courses.course_materials.retrieve.fleshed.atomic', - {course => $course_id} + {course => $course_id, is_active => 't'} ); return Apache2::Const::OK; } diff --git a/Open-ILS/src/sql/Pg/040.schema.asset.sql b/Open-ILS/src/sql/Pg/040.schema.asset.sql index 1b827bd798..7601282b13 100644 --- a/Open-ILS/src/sql/Pg/040.schema.asset.sql +++ b/Open-ILS/src/sql/Pg/040.schema.asset.sql @@ -1143,6 +1143,7 @@ CREATE TABLE asset.course_module_course_materials ( original_status INT REFERENCES config.copy_status, original_circ_modifier TEXT, --REFERENCES config.circ_modifier original_callnumber INT REFERENCES asset.call_number, + is_active BOOLEAN NOT NULL DEFAULT true, creator BIGINT NOT NULL REFERENCES actor.usr (id) DEFERRABLE INITIALLY DEFERRED, @@ -1151,6 +1152,7 @@ CREATE TABLE asset.course_module_course_materials ( DEFERRABLE INITIALLY DEFERRED, create_time TIMESTAMP WITH TIME ZONE DEFAULT NOW(), edit_time TIMESTAMP WITH TIME ZONE DEFAULT NOW(); + removal_time TIMESTAMP WITH TIME ZONE; unique (course, item, record) ); diff --git a/Open-ILS/src/sql/Pg/upgrade/xxxx.schema.lp1923057-course-material-removal-time.sql b/Open-ILS/src/sql/Pg/upgrade/xxxx.schema.lp1923057-course-material-removal-time.sql new file mode 100644 index 0000000000..c3a1ff88cd --- /dev/null +++ b/Open-ILS/src/sql/Pg/upgrade/xxxx.schema.lp1923057-course-material-removal-time.sql @@ -0,0 +1,8 @@ +BEGIN; + +SELECT evergreen.upgrade_deps_block_check('XXXX', :eg_version); +ALTER TABLE asset.course_module_course_materials + ADD COLUMN is_active BOOL NOT NULL DEFAULT true, + ADD COLUMN removal_time TIMESTAMP WITH TIME ZONE; + +COMMIT; \ No newline at end of file -- 2.11.0