[open-ils-commits] [GIT] Evergreen ILS branch master updated. 001ef6a6b0f4da8ea5a3606c415a9bbfe0a6a9d8

Evergreen Git git at git.evergreen-ils.org
Thu Mar 22 12:53:58 EDT 2012


This is an automated email from the git hooks/post-receive script. It was
generated because a ref change was pushed to the repository containing
the project "Evergreen ILS".

The branch, master has been updated
       via  001ef6a6b0f4da8ea5a3606c415a9bbfe0a6a9d8 (commit)
       via  0b02b2b552e25fee6104de200af621275d209396 (commit)
      from  16c872eb017b38dcfbeac9addc21edde1eacbfd5 (commit)

Those revisions listed above that are new to this repository have
not appeared on any other notification email; so we list those
revisions in full, below.

- Log -----------------------------------------------------------------
commit 001ef6a6b0f4da8ea5a3606c415a9bbfe0a6a9d8
Author: Dan Scott <dscott at laurentian.ca>
Date:   Thu Mar 22 12:53:13 2012 -0400

    Wrap upgrade script for CSV circ history export
    
    Thanks, Bill!
    
    Signed-off-by: Dan Scott <dscott at laurentian.ca>

diff --git a/Open-ILS/src/sql/Pg/upgrade/XXXX.data.circ_history_export_csv.sql b/Open-ILS/src/sql/Pg/upgrade/0688.data.circ_history_export_csv.sql
similarity index 82%
rename from Open-ILS/src/sql/Pg/upgrade/XXXX.data.circ_history_export_csv.sql
rename to Open-ILS/src/sql/Pg/upgrade/0688.data.circ_history_export_csv.sql
index 47cad2c..25e451b 100644
--- a/Open-ILS/src/sql/Pg/upgrade/XXXX.data.circ_history_export_csv.sql
+++ b/Open-ILS/src/sql/Pg/upgrade/0688.data.circ_history_export_csv.sql
@@ -1,6 +1,12 @@
-
+-- Evergreen DB patch 0688.data.circ_history_export_csv.sql
+--
+-- FIXME: insert description of change, if needed
+--
 BEGIN;
 
+-- check whether patch can be applied
+SELECT evergreen.upgrade_deps_block_check('0688', :eg_version);
+
 INSERT INTO action_trigger.hook (key, core_type, description, passive)
 VALUES (
     'circ.format.history.csv',
@@ -46,10 +52,3 @@ INSERT INTO action_trigger.environment (event_def, path)
     );
 
 COMMIT;
-
-/* UNDO
-DELETE FROM action_trigger.event WHERE event_def = (
-    SELECT id FROM action_trigger.event_definition WHERE hook = 'circ.format.history.csv');
-DELETE FROM action_trigger.event_definition WHERE hook = 'circ.format.history.csv');
-DELETE FROM action_trigger.hook WHERE key = 'circ.format.history.csv';
-*/

commit 0b02b2b552e25fee6104de200af621275d209396
Author: Bill Erickson <berick at esilibrary.com>
Date:   Wed Feb 22 13:14:13 2012 -0500

    TPac: Circulation history CSV export
    
    This adds a new "Download CSV" button to the TPac circulation history
    interface.  The CSV is generated from a new Action/Trigger event
    definition.
    
    Signed-off-by: Bill Erickson <berick at esilibrary.com>
    
    Conflicts:
    
    	Open-ILS/src/perlmods/lib/OpenILS/WWW/EGCatLoader/Util.pm
    	Open-ILS/src/sql/Pg/950.data.seed-values.sql
    
    Signed-off-by: Dan Scott <dan at coffeecode.net>

diff --git a/Open-ILS/src/perlmods/lib/OpenILS/WWW/EGCatLoader.pm b/Open-ILS/src/perlmods/lib/OpenILS/WWW/EGCatLoader.pm
index 14e0760..755f403 100644
--- a/Open-ILS/src/perlmods/lib/OpenILS/WWW/EGCatLoader.pm
+++ b/Open-ILS/src/perlmods/lib/OpenILS/WWW/EGCatLoader.pm
@@ -155,6 +155,7 @@ sub load {
     return $self->load_myopac_bookbags if $path =~ m|opac/myopac/lists|;
     return $self->load_myopac_bookbag_print if $path =~ m|opac/myopac/list/print|;
     return $self->load_myopac_bookbag_update if $path =~ m|opac/myopac/list/update|;
+    return $self->load_myopac_circ_history_export if $path =~ m|opac/myopac/circ_history/export|;
     return $self->load_myopac_circ_history if $path =~ m|opac/myopac/circ_history|;
     return $self->load_myopac_hold_history if $path =~ m|opac/myopac/hold_history|;
     return $self->load_myopac_prefs_notify if $path =~ m|opac/myopac/prefs_notify|;
diff --git a/Open-ILS/src/perlmods/lib/OpenILS/WWW/EGCatLoader/Account.pm b/Open-ILS/src/perlmods/lib/OpenILS/WWW/EGCatLoader/Account.pm
index 378bfd5..8e1e931 100644
--- a/Open-ILS/src/perlmods/lib/OpenILS/WWW/EGCatLoader/Account.pm
+++ b/Open-ILS/src/perlmods/lib/OpenILS/WWW/EGCatLoader/Account.pm
@@ -1907,8 +1907,6 @@ sub update_bookbag_item_notes {
 sub load_myopac_bookbag_print {
     my ($self) = @_;
 
-    $self->apache->content_type("text/plain; encoding=utf8");
-
     my $id = int($self->cgi->param("list"));
 
     my ($sorter, $modifier) = $self->_get_bookbag_sort_params("sort");
@@ -1950,12 +1948,34 @@ sub load_myopac_bookbag_print {
     # provoke browser download dialogs.
     (my $filename = $bbag->id . $bbag->name) =~ s/[^a-z0-9_ -]//gi;
 
-    $self->apache->headers_out->add(
-        "Content-Disposition",
-        "attachment;filename=$filename.csv"
+    return $self->set_file_download_headers("$filename.csv");
+}
+
+sub load_myopac_circ_history_export {
+    my $self = shift;
+    my $e = $self->editor;
+    my $filename = $self->cgi->param('filename') || 'circ_history.csv';
+
+    my $ids = $e->json_query({
+        select => {
+            au => [{
+                column => 'id', 
+                transform => 'action.usr_visible_circs', 
+                result_field => 'id'
+            }]
+        },
+        from => 'au',
+        where => {id => $e->requestor->id} 
+    });
+
+    $self->ctx->{csv} = $U->fire_object_event(
+        undef, 
+        'circ.format.history.csv',
+        $e->search_action_circulation({id => [map {$_->{id}} @$ids]}, {substream =>1}),
+        $self->editor->requestor->home_ou
     );
 
-    return Apache2::Const::OK;
+    return $self->set_file_download_headers($filename);
 }
 
 sub load_password_reset {
diff --git a/Open-ILS/src/perlmods/lib/OpenILS/WWW/EGCatLoader/Util.pm b/Open-ILS/src/perlmods/lib/OpenILS/WWW/EGCatLoader/Util.pm
index e672eac..b7c015b 100644
--- a/Open-ILS/src/perlmods/lib/OpenILS/WWW/EGCatLoader/Util.pm
+++ b/Open-ILS/src/perlmods/lib/OpenILS/WWW/EGCatLoader/Util.pm
@@ -392,6 +392,19 @@ sub load_copy_location_groups {
     $ctx->{copy_location_groups} = \%buckets;
 }
 
+sub set_file_download_headers {
+    my $self = shift;
+    my $filename = shift;
+    my $ctype = shift || "text/plain; encoding=utf8";
+
+    $self->apache->content_type($ctype);
 
+    $self->apache->headers_out->add(
+        "Content-Disposition",
+        "attachment;filename=$filename"
+    );
+
+    return Apache2::Const::OK;
+}
 
 1;
diff --git a/Open-ILS/src/sql/Pg/950.data.seed-values.sql b/Open-ILS/src/sql/Pg/950.data.seed-values.sql
index cec8061..3e6346b 100644
--- a/Open-ILS/src/sql/Pg/950.data.seed-values.sql
+++ b/Open-ILS/src/sql/Pg/950.data.seed-values.sql
@@ -11401,4 +11401,49 @@ INSERT INTO config.org_unit_setting_type
         'gui',
         'integer'
     );
+-- circ export csv export --
+
+INSERT INTO action_trigger.hook (key, core_type, description, passive)
+VALUES (
+    'circ.format.history.csv',
+    'circ',
+    oils_i18n_gettext(
+        'circ.format.history.csv',
+        'Produce CSV of circulation history',
+        'ath',
+        'description'
+    ),
+    FALSE
+);
+
+INSERT INTO action_trigger.event_definition (
+    active, owner, name, hook, reactor, validator, group_field, template) 
+VALUES (
+    TRUE, 1, 'Circ History CSV', 'circ.format.history.csv', 'ProcessTemplate', 'NOOP_True', 'usr',
+$$
+Title,Author,Call Number,Barcode,Format
+[%-
+FOR circ IN target;
+    bibxml = helpers.unapi_bre(circ.target_copy.call_number.record, {flesh => '{mra}'});
+    title = "";
+    FOR part IN bibxml.findnodes('//*[@tag="245"]/*[@code="a" or @code="b"]');
+        title = title _ part.textContent;
+    END;
+    author = bibxml.findnodes('//*[@tag="100"]/*[@code="a"]').textContent;
+    item_type = bibxml.findnodes('//*[local-name()="attributes"]/*[local-name()="field"][@name="item_type"]').getAttribute('coded-value') %]
+
+    [%- helpers.csv_datum(title) -%],
+    [%- helpers.csv_datum(author) -%],
+    [%- helpers.csv_datum(circ.target_copy.call_number.label) -%],
+    [%- helpers.csv_datum(circ.target_copy.barcode) -%],
+    [%- helpers.csv_datum(item_type) %]
+[%- END -%]
+$$
+);
+
+INSERT INTO action_trigger.environment (event_def, path)
+    VALUES (
+        currval('action_trigger.event_definition_id_seq'),
+        'target_copy.call_number'
+    );
 
diff --git a/Open-ILS/src/sql/Pg/upgrade/XXXX.data.circ_history_export_csv.sql b/Open-ILS/src/sql/Pg/upgrade/XXXX.data.circ_history_export_csv.sql
new file mode 100644
index 0000000..47cad2c
--- /dev/null
+++ b/Open-ILS/src/sql/Pg/upgrade/XXXX.data.circ_history_export_csv.sql
@@ -0,0 +1,55 @@
+
+BEGIN;
+
+INSERT INTO action_trigger.hook (key, core_type, description, passive)
+VALUES (
+    'circ.format.history.csv',
+    'circ',
+    oils_i18n_gettext(
+        'circ.format.history.csv',
+        'Produce CSV of circulation history',
+        'ath',
+        'description'
+    ),
+    FALSE
+);
+
+INSERT INTO action_trigger.event_definition (
+    active, owner, name, hook, reactor, validator, group_field, template) 
+VALUES (
+    TRUE, 1, 'Circ History CSV', 'circ.format.history.csv', 'ProcessTemplate', 'NOOP_True', 'usr',
+$$
+Title,Author,Call Number,Barcode,Format
+[%-
+FOR circ IN target;
+    bibxml = helpers.unapi_bre(circ.target_copy.call_number.record, {flesh => '{mra}'});
+    title = "";
+    FOR part IN bibxml.findnodes('//*[@tag="245"]/*[@code="a" or @code="b"]');
+        title = title _ part.textContent;
+    END;
+    author = bibxml.findnodes('//*[@tag="100"]/*[@code="a"]').textContent;
+    item_type = bibxml.findnodes('//*[local-name()="attributes"]/*[local-name()="field"][@name="item_type"]').getAttribute('coded-value') %]
+
+    [%- helpers.csv_datum(title) -%],
+    [%- helpers.csv_datum(author) -%],
+    [%- helpers.csv_datum(circ.target_copy.call_number.label) -%],
+    [%- helpers.csv_datum(circ.target_copy.barcode) -%],
+    [%- helpers.csv_datum(item_type) %]
+[%- END -%]
+$$
+);
+
+INSERT INTO action_trigger.environment (event_def, path)
+    VALUES (
+        currval('action_trigger.event_definition_id_seq'),
+        'target_copy.call_number'
+    );
+
+COMMIT;
+
+/* UNDO
+DELETE FROM action_trigger.event WHERE event_def = (
+    SELECT id FROM action_trigger.event_definition WHERE hook = 'circ.format.history.csv');
+DELETE FROM action_trigger.event_definition WHERE hook = 'circ.format.history.csv');
+DELETE FROM action_trigger.hook WHERE key = 'circ.format.history.csv';
+*/
diff --git a/Open-ILS/src/templates/opac/myopac/circ_history.tt2 b/Open-ILS/src/templates/opac/myopac/circ_history.tt2
index 0728245..4e8c861 100644
--- a/Open-ILS/src/templates/opac/myopac/circ_history.tt2
+++ b/Open-ILS/src/templates/opac/myopac/circ_history.tt2
@@ -26,8 +26,14 @@
             <a href='[% mkurl('circ_history', {limit => limit, offset => (offset + limit)}) %]'
                [% IF ctx.circs.size < limit %] class='invisible' [% END %] >[% l('Next') %]<span class="nav_arrow_fix">&#9658;</span></a>
         </span>
-        <span class="float-right">
-            <a class="hide_me" href="#">[% l('Export List') %]</a>
+        <span class="float-left">
+            <form action="[% mkurl(ctx.opac_root _ '/myopac/circ_history/export') %]" method="POST">
+                <div>
+                    [%- INCLUDE "opac/parts/preserve_params.tt2" %]
+                    <input type="hidden" name="filename" value="[% l('circ_history.csv') %]"/> 
+                    <button type="submit">[% l('Download CSV') %]</button>
+                </div>
+            </form>
         </span>
     </div>
     <div class="clear-both"></div>
diff --git a/Open-ILS/src/templates/opac/myopac/circ_history/export.tt2 b/Open-ILS/src/templates/opac/myopac/circ_history/export.tt2
new file mode 100644
index 0000000..fa3988f
--- /dev/null
+++ b/Open-ILS/src/templates/opac/myopac/circ_history/export.tt2
@@ -0,0 +1 @@
+[%- ctx.csv.template_output.data -%]

-----------------------------------------------------------------------

Summary of changes:
 .../src/perlmods/lib/OpenILS/WWW/EGCatLoader.pm    |    1 +
 .../lib/OpenILS/WWW/EGCatLoader/Account.pm         |   32 +++++++++--
 .../perlmods/lib/OpenILS/WWW/EGCatLoader/Util.pm   |   13 +++++
 Open-ILS/src/sql/Pg/950.data.seed-values.sql       |   45 ++++++++++++++++
 .../upgrade/0688.data.circ_history_export_csv.sql  |   54 ++++++++++++++++++++
 .../src/templates/opac/myopac/circ_history.tt2     |   10 +++-
 .../{list/print.tt2 => circ_history/export.tt2}    |    0
 7 files changed, 147 insertions(+), 8 deletions(-)
 create mode 100644 Open-ILS/src/sql/Pg/upgrade/0688.data.circ_history_export_csv.sql
 copy Open-ILS/src/templates/opac/myopac/{list/print.tt2 => circ_history/export.tt2} (100%)


hooks/post-receive
-- 
Evergreen ILS


More information about the open-ils-commits mailing list