Overhauling the Tattler mechanism collab/blake/tattle-tale-squashed
authorLlewellyn Marshall <llewellyn.marshall@ncdcr.gov>
Tue, 23 Jun 2020 20:29:31 +0000 (16:29 -0400)
committerblake <blake@mobiusconsortium.org>
Tue, 19 Jan 2021 18:28:39 +0000 (12:28 -0600)
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 <blake@mobiusconsortium.org>
Open-ILS/examples/fm_IDL.xml
Open-ILS/src/perlmods/lib/OpenILS/WWW/EGCatLoader.pm
Open-ILS/src/perlmods/lib/OpenILS/WWW/EGCatLoader/Tattler.pm [new file with mode: 0644]
Open-ILS/src/templates/opac/tattler.tt2 [new file with mode: 0644]

index a312c10..c248695 100644 (file)
@@ -13255,6 +13255,13 @@ SELECT  usr,
                        </actions>
                </permacrud>
        </class>
+    <class id="sdil" controller="open-ils.cstore" oils_obj:fieldmapper="seekdestroy::ignore_list" oils_persist:tablename="seekdestroy.ignore_list" reporter:label="Seek and Destroy Ignore List">
+               <fields oils_persist:primary="id" oils_persist:sequence="seekdestroy.ignore_list_id_seq">
+                       <field reporter:label="ID" name="id" reporter:datatype="id" />
+                       <field reporter:label="Report ID" name="report" reporter:datatype="int"/>
+                       <field reporter:label="Copy ID" name="target_copy" reporter:datatype="int"/>
+               </fields>
+       </class>
 
        <!-- no pcrud access is granted for now, because it's assumed these
                         setting values will be applied and retrived via the API. -->
index 663cde6..b652048 100644 (file)
@@ -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 (file)
index 0000000..b1026c7
--- /dev/null
@@ -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 (file)
index 0000000..da9937f
--- /dev/null
@@ -0,0 +1 @@
+[%- ctx.status; -%]
\ No newline at end of file