[open-ils-commits] ***SPAM*** [GIT] Evergreen ILS branch rel_2_4 updated. 334569313539c45de6b279fa25f39715c3f5be7d

Evergreen Git git at git.evergreen-ils.org
Thu Feb 6 14:42:01 EST 2014


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, rel_2_4 has been updated
       via  334569313539c45de6b279fa25f39715c3f5be7d (commit)
      from  0da485a3469a9a34c6267b6549d8319835bccfc6 (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 334569313539c45de6b279fa25f39715c3f5be7d
Author: Bill Erickson <berick at esilibrary.com>
Date:   Thu Jan 9 11:24:08 2014 -0500

    LP#1164720 Prevent empty names in TPAC lists
    
    Form submission for list creation with an empty name value now prevents
    list creation and redirects the user to a new error page explaining why
    list creation failed.
    
    Signed-off-by: Bill Erickson <berick at esilibrary.com>
    Signed-off-by: Ben Shum <bshum at biblio.org>

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 ec7bb96..6386652 100644
--- a/Open-ILS/src/perlmods/lib/OpenILS/WWW/EGCatLoader/Account.pm
+++ b/Open-ILS/src/perlmods/lib/OpenILS/WWW/EGCatLoader/Account.pm
@@ -1799,9 +1799,15 @@ sub load_myopac_bookbags {
         $self->ctx->{add_rec} = $add_rec;
         # But not in the staff client, 'cause that breaks things.
         unless ($self->ctx->{is_staff}) {
-            $self->ctx->{where_from} = $self->ctx->{referer};
-            if ( my $anchor = $self->cgi->param('anchor') ) {
-                $self->ctx->{where_from} =~ s/#.*|$/#$anchor/;
+            # allow caller to provide the where_from in cases where
+            # the referer is an intermediate error page
+            if ($self->cgi->param('where_from')) {
+                $self->ctx->{where_from} = $self->cgi->param('where_from');
+            } else {
+                $self->ctx->{where_from} = $self->ctx->{referer};
+                if ( my $anchor = $self->cgi->param('anchor') ) {
+                    $self->ctx->{where_from} =~ s/#.*|$/#$anchor/;
+                }
             }
         }
     }
@@ -1849,26 +1855,33 @@ sub load_myopac_bookbag_update {
     }
 
     if ($action eq 'create') {
-        $list = Fieldmapper::container::biblio_record_entry_bucket->new;
-        $list->name($name);
-        $list->description($description);
-        $list->owner($e->requestor->id);
-        $list->btype('bookbag');
-        $list->pub($shared ? 't' : 'f');
-        $success = $U->simplereq('open-ils.actor',
-            'open-ils.actor.container.create', $e->authtoken, 'biblio', $list);
-        if (ref($success) ne 'HASH' && scalar @add_rec) {
-            $list_id = (ref($success)) ? $success->id : $success;
-            foreach my $add_rec (@add_rec) {
-                my $item = Fieldmapper::container::biblio_record_entry_bucket_item->new;
-                $item->bucket($list_id);
-                $item->target_biblio_record_entry($add_rec);
-                $success = $U->simplereq('open-ils.actor',
-                                         'open-ils.actor.container.item.create', $e->authtoken, 'biblio', $item);
-                last unless $success;
+
+        if ($name) {
+            $list = Fieldmapper::container::biblio_record_entry_bucket->new;
+            $list->name($name);
+            $list->description($description);
+            $list->owner($e->requestor->id);
+            $list->btype('bookbag');
+            $list->pub($shared ? 't' : 'f');
+            $success = $U->simplereq('open-ils.actor',
+                'open-ils.actor.container.create', $e->authtoken, 'biblio', $list);
+            if (ref($success) ne 'HASH' && scalar @add_rec) {
+                $list_id = (ref($success)) ? $success->id : $success;
+                foreach my $add_rec (@add_rec) {
+                    my $item = Fieldmapper::container::biblio_record_entry_bucket_item->new;
+                    $item->bucket($list_id);
+                    $item->target_biblio_record_entry($add_rec);
+                    $success = $U->simplereq('open-ils.actor',
+                                             'open-ils.actor.container.item.create', $e->authtoken, 'biblio', $item);
+                    last unless $success;
+                }
             }
             $url = $cgi->param('where_from') if ($success && $cgi->param('where_from'));
+
+        } else { # no name
+            $self->ctx->{bucket_failure_noname} = 1;
         }
+
     } elsif($action eq 'place_hold') {
 
         # @hold_recs comes from anon lists redirect; selected_itesm comes from existing buckets
@@ -1986,9 +1999,7 @@ sub load_myopac_bookbag_update {
 
     return $self->generic_redirect($url) if $success;
 
-    # XXX FIXME Bucket failure doesn't have a page to show the user anything
-    # right now. User just sees a 404 currently.
-
+    $self->ctx->{where_from} = $cgi->param('where_from');
     $self->ctx->{bucket_action} = $action;
     $self->ctx->{bucket_action_failed} = 1;
     return Apache2::Const::OK;
diff --git a/Open-ILS/src/templates/opac/myopac/list/update.tt2 b/Open-ILS/src/templates/opac/myopac/list/update.tt2
new file mode 100644
index 0000000..2275df6
--- /dev/null
+++ b/Open-ILS/src/templates/opac/myopac/list/update.tt2
@@ -0,0 +1,44 @@
+[%  PROCESS "opac/parts/header.tt2";
+    PROCESS "opac/parts/misc_util.tt2";
+    WRAPPER "opac/parts/myopac/base.tt2";
+    myopac_page = "lists/update"  
+%]
+
+<!-- we should never see this page on success -->
+
+[% IF ctx.bucket_action_failed %]
+<div id='bookbag_udpate_failures'>
+
+  <div>
+    <strong>[% l("Problem with list management:") %]</strong>
+  </div>
+
+  <div>
+    <ul>
+    [% IF ctx.bucket_action == 'create' %]
+      [% IF ctx.bucket_failure_noname %]         
+        <li>[% l('A list name is required') %]</li>
+      [% END %]   
+    [% END %]   
+    </ul>
+  </div>
+
+  <div>
+    [% url = ctx.referer;
+      # The return link should return the user to the page where the edit
+      # failure occurred.
+      # mkurl() does not support 'page' params w/ existing CGI params.
+      # build the URL manually.
+      IF ctx.where_from;
+        from = ctx.where_from | uri;
+        IF url.match('\?');
+          url = url _ ';where_from=' _ from;
+        ELSE;
+          url = url _ '?where_from=' _ from;
+        END;
+      END; %]
+    <a href="[% url %]">[% l('Return') %]</a>
+  </div>
+</div>
+[% END %]
+[% END %]

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

Summary of changes:
 .../lib/OpenILS/WWW/EGCatLoader/Account.pm         |   57 ++++++++++++--------
 Open-ILS/src/templates/opac/myopac/list/update.tt2 |   44 +++++++++++++++
 2 files changed, 78 insertions(+), 23 deletions(-)
 create mode 100644 Open-ILS/src/templates/opac/myopac/list/update.tt2


hooks/post-receive
-- 
Evergreen ILS


More information about the open-ils-commits mailing list