More power to present friendly messages when hold placement fails
authorLebbeous Fogle-Weekley <lebbeous@esilibrary.com>
Wed, 20 Jul 2011 22:02:47 +0000 (18:02 -0400)
committerLebbeous Fogle-Weekley <lebbeous@esilibrary.com>
Wed, 20 Jul 2011 22:02:47 +0000 (18:02 -0400)
This area could use a little cleanup, elegance, but it can give end
users better messages for a diverse set of reasons why hold placement
failed.

Signed-off-by: Lebbeous Fogle-Weekley <lebbeous@esilibrary.com>
Open-ILS/web/templates/default/opac/parts/hold_error_messages.tt2 [new file with mode: 0644]
Open-ILS/web/templates/default/opac/parts/place_hold.tt2

diff --git a/Open-ILS/web/templates/default/opac/parts/hold_error_messages.tt2 b/Open-ILS/web/templates/default/opac/parts/hold_error_messages.tt2
new file mode 100644 (file)
index 0000000..9ba6f0e
--- /dev/null
@@ -0,0 +1,38 @@
+[%
+    # XXX It might be cleaner to move this into its own file or something.
+    #
+    # The following hash should have fail_parts as keys and user/patron-friendly
+    # strings as values.  If the system returns an event with a fail_part when
+    # you attempt to place a hold and the fail part matches something in this
+    # hash, this is the message that will be displayed to the user. Wait until
+    # these are used to pass them through l() for i18n.
+
+    FAIL_PART_MSG_MAP = {
+        "actor.usr.barred" => "The patron is barred",
+        "asset.copy.circulate" => "The item does not circulate",
+        "asset.copy_location.circulate" => "Items from this shelving location do not circulate",
+        "asset.copy.status" => "The item cannot circulate at this time",
+        "circ.holds.target_skip_me" => "The item's circulation library does not fulfill holds",
+        "config.circ_matrix_circ_mod_test" => "The patron has too many items of this type checked out",
+        "config.circ_matrix_test.available_copy_hold_ratio" => "The available item-to-hold ratio is too low",
+        "config.circ_matrix_test.circulate" => "Circulation rules reject this item as non-circulatable",
+        "config.circ_matrix_test.total_copy_hold_ratio" => "The total item-to-hold ratio is too low",
+        "config.hold_matrix_test.holdable" => "Hold rules reject this item as unholdable",
+        "config.hold_matrix_test.max_holds" => "The patron has reached the maximum number of holds",
+        "config.rule_age_hold_protect.prox" => "The item is too new to transit this far",
+        "no_item" => "The system could not find this item",
+        "no_ultimate_items" => "The system could not find any items to match this hold request",
+        "no_matchpoint" => "System rules do not define how to handle this item",
+        "no_user" => "The system could not find this patron",
+        "transit_range" => "The item cannot transit this far"
+    };
+
+
+    # This works like the above has, but instead of fail_parts for keys, use
+    # the textcode of the event.  This will only be consulted for events
+    # that do not have a fail_part matching something in the above hash.
+    # Wait until these are used to pass them through l() for i18n.
+
+    EVENT_MSG_MAP = {
+    };
+%]
index 8ca6075..861a987 100644 (file)
@@ -1,6 +1,8 @@
 [%  PROCESS "default/opac/parts/misc_util.tt2";
     attrs = {marc_xml => ctx.marc_xml};
     PROCESS get_marc_attrs args=attrs;
+
+    PROCESS "default/opac/parts/hold_error_messages.tt2";
 %]
 <div>
     <div id='holds_box' class='canvas' style='margin-top: 6px;'>
         <div>
             <strong>[% l('Problem:') %]</strong>
             <span title="[% ctx.hold_failed_event.textcode %]">
-                <em>[% ctx.hold_failed_event.desc ||
+                <em>[%
+                        fail_part_key = ctx.hold_failed_event.payload.fail_part;
+                        event_key = ctx.hold_failed_event.textcode;
+
+                        # display:
+                        l(FAIL_PART_MSG_MAP.$fail_part_key) ||
+                        l(EVENT_MSG_MAP.$event_key) ||
+                        l(ctx.hold_failed_event.desc) ||
                         ctx.hold_failed_event.payload.fail_part ||
                         ctx.hold_failed_event.textcode ||
                         (ctx.hold_local_alert ?