[open-ils-commits] [GIT] Evergreen ILS branch master updated. 1cb6a1ebb36d44985feca77d10c1848b838bd275

Evergreen Git git at git.evergreen-ils.org
Tue Oct 9 13:57:52 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  1cb6a1ebb36d44985feca77d10c1848b838bd275 (commit)
       via  09a85ef0dddb9bf05bff352b4b4bccfb219ee8c1 (commit)
      from  95f607400e1adc51c8dea8c38a917ed85c7c2772 (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 1cb6a1ebb36d44985feca77d10c1848b838bd275
Author: Dan Scott <dan at coffeecode.net>
Date:   Mon Oct 8 15:08:47 2012 -0400

    Checkout: further validation of due date override
    
    The check_past() function failed if given a date that was not strictly
    in YYYY-mm-dd format; interestingly, a common transposition typo such
    as "0212-10-20" results in "212-10-20" getting passed to check_past(),
    and therefore generating an invalid date. Throw an exception in
    check_past() rather than returning true, because we are not in fact
    stating that the due date is in the past - and catch the exception and
    flag the due date override box accordingly in the checkout screen.
    
    We could bubble the exception up to the user, but hopefully highlighting
    the checkout box as being in an invalid state will catch the attention
    of the users.
    
    [LFW: Slightly amended a comment in OpenILS/WWW/EGCatLoader/Util.pm]
    
    Signed-off-by: Dan Scott <dan at coffeecode.net>
    Signed-off-by: Lebbeous Fogle-Weekley <lebbeous at esilibrary.com>

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 04360af..470e381 100644
--- a/Open-ILS/src/perlmods/lib/OpenILS/WWW/EGCatLoader/Util.pm
+++ b/Open-ILS/src/perlmods/lib/OpenILS/WWW/EGCatLoader/Util.pm
@@ -184,7 +184,7 @@ sub init_ro_object_cache {
         my $date = shift;
 
         # Probably an accidental entry like '0212' instead of '2012',
-        # but 1) the leading 0 gets stripped in CStoreEditor and
+        # but 1) the leading 0 may get stripped in cstore and
         # 2) DateTime::Format::ISO8601 returns an error as years
         # must be 2 or 4 digits
         if ($date =~ m/^\d{3}-/) {
diff --git a/Open-ILS/xul/staff_client/chrome/content/util/date.js b/Open-ILS/xul/staff_client/chrome/content/util/date.js
index fb95bee..47c3e21 100644
--- a/Open-ILS/xul/staff_client/chrome/content/util/date.js
+++ b/Open-ILS/xul/staff_client/chrome/content/util/date.js
@@ -24,8 +24,16 @@ util.date.check = function(format,date) {
 
 util.date.check_past = function(format,date) {
     if (format != 'YYYY-MM-DD') { throw('I only understand YYYY-MM-DD.  Fix me if you want.'); }
-    var yyyy = date.substr(0,4); var mm = date.substr(5,2); var dd = date.substr(8,2);
+    var yyyy = date.substr(0,4);
+    var mm = date.substr(5,2);
+    var dd = date.substr(8,2);
     var test_date = new Date( yyyy, mm - 1, dd );
+
+    /* Ensure our date is valid */
+    if (isNaN(test_date.getTime())) {
+        throw('The date "' + date + '" is not valid.');
+    }
+
     date = util.date.formatted_date(new Date(),'%F');
     yyyy = date.substr(0,4); mm = date.substr(5,2); dd = date.substr(8,2);
     var today = new Date( yyyy, mm - 1, dd );
diff --git a/Open-ILS/xul/staff_client/server/circ/checkout.js b/Open-ILS/xul/staff_client/server/circ/checkout.js
index 87a2115..08455c3 100644
--- a/Open-ILS/xul/staff_client/server/circ/checkout.js
+++ b/Open-ILS/xul/staff_client/server/circ/checkout.js
@@ -120,7 +120,7 @@ circ.checkout.prototype = {
                         ['change'],
                         function(ev) { 
                             try {
-				document.getElementById('checkout_duedate_checkbox').checked = true;
+                                document.getElementById('checkout_duedate_checkbox').checked = true;
                                 if (obj.check_date(ev.target)) {
                                     ev.target.parentNode.setAttribute('style','');
                                 } else {
@@ -348,10 +348,17 @@ circ.checkout.prototype = {
             obj.controller.view.checkout_barcode_entry_textbox.disabled = false;
             obj.controller.view.cmd_checkout_submit.setAttribute('disabled','false');
             obj.controller.view.cmd_checkout_submit.disabled = false;
-            if (util.date.check_past('YYYY-MM-DD',node.value) ) {
-                obj.controller.view.checkout_barcode_entry_textbox.setAttribute('disabled','true');
-                obj.controller.view.cmd_checkout_submit.setAttribute('disabled','true');
-                return false;
+            try {
+                if (util.date.check_past('YYYY-MM-DD',node.value) ) {
+                    obj.controller.view.checkout_barcode_entry_textbox.setAttribute('disabled','true');
+                    obj.controller.view.cmd_checkout_submit.setAttribute('disabled','true');
+                    return false;
+                }
+            }
+            catch (E) {
+                    obj.controller.view.checkout_barcode_entry_textbox.setAttribute('disabled','true');
+                    obj.controller.view.cmd_checkout_submit.setAttribute('disabled','true');
+                    return false;
             }
             return true;
         } catch(E) {

commit 09a85ef0dddb9bf05bff352b4b4bccfb219ee8c1
Author: Dan Scott <dan at coffeecode.net>
Date:   Mon Oct 8 11:25:41 2012 -0400

    TPAC: Invalid due dates cause 500 server error
    
    CStore appears to return dates with leading 0s (such as '0212-10-08
    23:59:59-05:17:32') with the leading 0s stripped off, resulting in
    cases with 1-digit or 3-digit years for which DateTime::Format::ISO8601
    returns an error.
    
    We can protect against this problem by adding some defensive code to the
    TPAC utility method to add the 0s back to the start of the year. We can
    also log the problem when it occurs so that administrators can fix the
    problem dates in the database.
    
    Signed-off-by: Dan Scott <dan at coffeecode.net>
    Signed-off-by: Lebbeous Fogle-Weekley <lebbeous at esilibrary.com>

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 e7e3bd1..04360af 100644
--- a/Open-ILS/src/perlmods/lib/OpenILS/WWW/EGCatLoader/Util.pm
+++ b/Open-ILS/src/perlmods/lib/OpenILS/WWW/EGCatLoader/Util.pm
@@ -182,7 +182,22 @@ sub init_ro_object_cache {
     # turns an ISO date into something TT can understand
     $ro_object_subs->{parse_datetime} = sub {
         my $date = shift;
-        $date = DateTime::Format::ISO8601->new->parse_datetime(cleanse_ISO8601($date));
+
+        # Probably an accidental entry like '0212' instead of '2012',
+        # but 1) the leading 0 gets stripped in CStoreEditor and
+        # 2) DateTime::Format::ISO8601 returns an error as years
+        # must be 2 or 4 digits
+        if ($date =~ m/^\d{3}-/) {
+            $logger->warn("Invalid date had a 3-digit year: $date");
+            $date = '0' . $date;
+        } elsif ($date =~ m/^\d{1}-/) {
+            $logger->warn("Invalid date had a 1-digit year: $date");
+            $date = '000' . $date;
+        }
+
+        my $cleansed_date = cleanse_ISO8601($date);
+
+        $date = DateTime::Format::ISO8601->new->parse_datetime($cleansed_date);
         return sprintf(
             "%0.2d:%0.2d:%0.2d %0.2d-%0.2d-%0.4d",
             $date->hour,

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

Summary of changes:
 .../perlmods/lib/OpenILS/WWW/EGCatLoader/Util.pm   |   17 ++++++++++++++++-
 .../xul/staff_client/chrome/content/util/date.js   |   10 +++++++++-
 Open-ILS/xul/staff_client/server/circ/checkout.js  |   17 ++++++++++++-----
 3 files changed, 37 insertions(+), 7 deletions(-)


hooks/post-receive
-- 
Evergreen ILS


More information about the open-ils-commits mailing list