From 10f91d0a5f2b46682c69d9cb5fd1b0d4bb132d7d Mon Sep 17 00:00:00 2001 From: Llewellyn Marshall Date: Tue, 23 Jun 2020 16:29:31 -0400 Subject: [PATCH] Overhauling the Tattler mechanism This commit moves most of the functionality into: https://github.com/mcoia/mobius_evergreen/tree/seek_and_destroy_tattle_tale_reporting This code has been condensed into a single web call that responds with 0,1,2 depending on the state of seekdestroy.ignore_list. The table creation is not included as it's part of the main seek_and_destroy code right now. Removing the dbi modules. Not needed Removed Makefile changes TODO: Fully integrate the seek and destroy funcationality into Evergreen, including: new schema action triggers catalog administration interfaces catalog participation interfaces Removing the dbi modules. Not needed Signed-off-by: blake --- Open-ILS/examples/fm_IDL.xml | 7 +++ .../src/perlmods/lib/OpenILS/WWW/EGCatLoader.pm | 3 ++ .../lib/OpenILS/WWW/EGCatLoader/Tattler.pm | 52 ++++++++++++++++++++++ Open-ILS/src/templates/opac/tattler.tt2 | 1 + 4 files changed, 63 insertions(+) create mode 100644 Open-ILS/src/perlmods/lib/OpenILS/WWW/EGCatLoader/Tattler.pm create mode 100644 Open-ILS/src/templates/opac/tattler.tt2 diff --git a/Open-ILS/examples/fm_IDL.xml b/Open-ILS/examples/fm_IDL.xml index a312c105ef..c248695dd2 100644 --- a/Open-ILS/examples/fm_IDL.xml +++ b/Open-ILS/examples/fm_IDL.xml @@ -13255,6 +13255,13 @@ SELECT usr, + + + + + + + diff --git a/Open-ILS/src/perlmods/lib/OpenILS/WWW/EGCatLoader.pm b/Open-ILS/src/perlmods/lib/OpenILS/WWW/EGCatLoader.pm index 663cde60d4..b652048db9 100644 --- a/Open-ILS/src/perlmods/lib/OpenILS/WWW/EGCatLoader.pm +++ b/Open-ILS/src/perlmods/lib/OpenILS/WWW/EGCatLoader.pm @@ -22,6 +22,7 @@ use OpenILS::WWW::EGCatLoader::Util; use OpenILS::WWW::EGCatLoader::Account; use OpenILS::WWW::EGCatLoader::Browse; use OpenILS::WWW::EGCatLoader::Library; +use OpenILS::WWW::EGCatLoader::Tattler; use OpenILS::WWW::EGCatLoader::Search; use OpenILS::WWW::EGCatLoader::Record; use OpenILS::WWW::EGCatLoader::Course; @@ -275,6 +276,8 @@ sub load { return $self->load_myopac_prefs if $path =~ m|opac/myopac/prefs|; return $self->load_myopac_reservations if $path =~ m|opac/myopac/reservations|; + return $self->update_tattle_list if $path =~ m|opac/tattler|; + return Apache2::Const::OK; } diff --git a/Open-ILS/src/perlmods/lib/OpenILS/WWW/EGCatLoader/Tattler.pm b/Open-ILS/src/perlmods/lib/OpenILS/WWW/EGCatLoader/Tattler.pm new file mode 100644 index 0000000000..b1026c7f83 --- /dev/null +++ b/Open-ILS/src/perlmods/lib/OpenILS/WWW/EGCatLoader/Tattler.pm @@ -0,0 +1,52 @@ +package OpenILS::WWW::EGCatLoader; +use strict; use warnings; +use Apache2::Const -compile => qw(OK DECLINED FORBIDDEN HTTP_INTERNAL_SERVER_ERROR REDIRECT HTTP_BAD_REQUEST); +use OpenSRF::Utils::JSON; +use OpenSRF::Utils::Logger qw/$logger/; +use OpenILS::Utils::CStoreEditor qw/:funcs/; +use OpenILS::Utils::Fieldmapper; +use OpenILS::Application::AppUtils; + +my $U = 'OpenILS::Application::AppUtils'; + +sub update_tattle_list { + my $self = shift; + my $ctx = $self->ctx; + my $cgi = $self->cgi; + my $usr = $ctx->{user}; + my $permission = $usr && $self->{editor}->allowed('UPDATE_RECORD'); + return Apache2::Const::FORBIDDEN unless $permission; + my $copy_id = $cgi->param('copyid'); + my $report = $cgi->param('reportid'); + if( $copy_id && $report ) { + my $already_exists = $self->{editor}->json_query({ + select => { sdil => ['id'] }, + from => 'sdil', + where => { + report => $report, + target_copy => $copy_id + } + }); + if( @$already_exists[0] ) { + $logger->info("Seek and Destroy Ignore report: $report, copy: $copy_id already exists"); + $ctx->{status} = 2; + return Apache2::Const::OK; + } + $self->{editor}->xact_begin; + my $rec = Fieldmapper::seekdestroy::ignore_list->new; + $logger->info("Adding copy to seekdestory ignore list for $report on copy $copy_id"); + $rec->target_copy($copy_id); + $rec->report($report); + $self->{editor}->create_seekdestroy_ignore_list($rec); + $self->{editor}->xact_commit; + $ctx->{status} = 1; + } + else { + $logger->info("Failed seekdestory ignore list for $report on copy $copy_id"); + $ctx->{status} = 0; + } + + return Apache2::Const::OK; +} + +1; \ No newline at end of file diff --git a/Open-ILS/src/templates/opac/tattler.tt2 b/Open-ILS/src/templates/opac/tattler.tt2 new file mode 100644 index 0000000000..da9937fe3c --- /dev/null +++ b/Open-ILS/src/templates/opac/tattler.tt2 @@ -0,0 +1 @@ +[%- ctx.status; -%] \ No newline at end of file -- 2.11.0