Add PLACE_UNFILLABLE_HOLD permission
authorThomas Berezansky <tsbere@mvlc.org>
Sat, 14 Jan 2012 14:58:33 +0000 (09:58 -0500)
committerMike Rylander <mrylander@gmail.com>
Thu, 29 Mar 2012 17:33:07 +0000 (13:33 -0400)
And hook it up in JSPac and TPac.

General idea: If you have the permission you can place holds that will not
fill right now, in general, for any reason.

In TPac, I replaced the previous "check the last failure code" line. The
new permission basically accomplishes the same thing for now, and is less
likely to return different results from placement attempt to placement
attempt. Also, only checking one failure code of potential hundreds didn't
make a lot of sense.

In the event of age protected copies the age protected prompt wins out.

Signed-off-by: Thomas Berezansky <tsbere@mvlc.org>
Signed-off-by: Mike Rylander <mrylander@gmail.com>

Open-ILS/src/perlmods/lib/OpenILS/Application/Circ/Holds.pm
Open-ILS/src/perlmods/lib/OpenILS/WWW/EGCatLoader/Account.pm
Open-ILS/src/sql/Pg/950.data.seed-values.sql
Open-ILS/src/sql/Pg/upgrade/XXXX.place_unfillable_hold.sql [new file with mode: 0644]
Open-ILS/web/opac/locale/en-US/opac.dtd
Open-ILS/web/opac/skin/default/js/holds.js
Open-ILS/web/opac/skin/default/xml/common/holds.xml

index 5c840c5..70325f9 100644 (file)
@@ -2254,6 +2254,9 @@ sub check_title_hold {
         @status = do_possibility_checks($e, $patron, $request_lib, $params{depth}, %params);
     }
 
+    my $place_unfillable = 0;
+    $place_unfillable = 1 if $e->allowed('PLACE_UNFILLABLE_HOLD', $e->requestor->ws_ou);
+
     if ($status[0]) {
         return {
             "success" => 1,
@@ -2262,9 +2265,9 @@ sub check_title_hold {
         };
     } elsif ($status[2]) {
         my $n = scalar @{$status[2]};
-        return {"success" => 0, "last_event" => $status[2]->[$n - 1], "age_protected_copy" => $status[3]};
+        return {"success" => 0, "last_event" => $status[2]->[$n - 1], "age_protected_copy" => $status[3], "place_unfillable" => $place_unfillable};
     } else {
-        return {"success" => 0, "age_protected_copy" => $status[3]};
+        return {"success" => 0, "age_protected_copy" => $status[3], "place_unfillable" => $place_unfillable};
     }
 }
 
index 8e1e931..72f4601 100644 (file)
@@ -904,7 +904,7 @@ sub attempt_hold_placement {
                             $hdata->{could_override} = 1;
                             $hdata->{age_protect} = 1;
                         } else {
-                            $hdata->{could_override} = $self->test_could_override($hdata->{hold_failed_event});
+                            $hdata->{could_override} = $result->{place_unfillable};
                         }
                     } elsif (ref $result eq 'ARRAY') {
                         $hdata->{hold_failed_event} = $result->[0];
@@ -913,7 +913,7 @@ sub attempt_hold_placement {
                             $hdata->{could_override} = 1;
                             $hdata->{age_protect} = 1;
                         } else {
-                            $hdata->{could_override} = $self->test_could_override($hdata->{hold_failed_event});
+                            $hdata->{could_override} = $result->[4]; # place_unfillable
                         }
                     }
                 }
index b6b88d4..bd9fc24 100644 (file)
@@ -1535,7 +1535,9 @@ INSERT INTO permission.perm_list ( id, code, description ) VALUES
  ( 522, 'IMPORT_AUTHORITY_MARC', oils_i18n_gettext( 522,
     'Allows a user to create new authority records', 'ppl', 'description' )),
  ( 523, 'ADMIN_TOOLBAR', oils_i18n_gettext( 523,
-    'Allows a user to create, edit, and delete custom toolbars', 'ppl', 'description' ));
+    'Allows a user to create, edit, and delete custom toolbars', 'ppl', 'description' )),
+ ( 524, 'PLACE_UNFILLABLE_HOLD', oils_i18n_gettext( 524,
+    'Allows a user to place a hold that cannot currently be filled.', 'ppl', 'description' ));
 
 SELECT SETVAL('permission.perm_list_id_seq'::TEXT, 1000);
 
diff --git a/Open-ILS/src/sql/Pg/upgrade/XXXX.place_unfillable_hold.sql b/Open-ILS/src/sql/Pg/upgrade/XXXX.place_unfillable_hold.sql
new file mode 100644 (file)
index 0000000..559510e
--- /dev/null
@@ -0,0 +1,3 @@
+INSERT INTO permission.perm_list ( id, code, description ) VALUES
+ ( 524, 'PLACE_UNFILLABLE_HOLD', oils_i18n_gettext( 524,
+    'Allows a user to place a hold that cannot currently be filled.', 'ppl', 'description' ));
index ef17a45..6ac79e6 100644 (file)
@@ -620,6 +620,7 @@ We recommend that you remove this title from any bookbags it may have been added
 <!ENTITY common.hold.exists "A hold already exists on the requested item.">
 <!ENTITY common.hold.exists.override "A hold already exists on the requested item. Would you like to create the hold anyway?">
 <!ENTITY common.hold.age_protect.override "This hold may take extra time to fill due to library policies. Would you like to create the hold anyway?">
+<!ENTITY common.hold.place_unfillable.override "The requested hold cannot currently be filled. You have permission to place the hold regardless, but should only do so if you know the hold will eventually be fillable. Would you like to create the hold anyway?">
 <!ENTITY common.hold.barred 'PATRON BARRED. Please see any notes in the
 "Staff Notes" section of your "My Account" page or contact your local library.'>
 <!ENTITY common.hold.item.invalid "This hold is no longer valid. It's likely that the
index 15e7bc2..5c4a324 100644 (file)
@@ -1022,18 +1022,27 @@ function holdHandleCreateResponse(r, recurse) {
 
        if(!recurse) {
                var res = r.getResultObject();
-        var age_protect_override = false;;
+        var place_anyway = false;
                if(checkILSEvent(res) || res.success != 1) {
-            if(res.success != 1 && res.age_protected_copy == 1) {
-                // There is at least one copy that *could* fill the hold, if it were not age-protected.
-                if( confirm($('hold_age_protected_override').innerHTML) ) {
-                    age_protect_override = true;
-                } else {
-                       swapCanvas($('holds_box'));
-                           return;
+            if(res.success != 1) {
+                if(res.age_protected_copy == 1) {
+                    // There is at least one copy that *could* fill the hold, if it were not age-protected.
+                    if( confirm($('hold_age_protected_override').innerHTML) ) {
+                        place_anyway = true;
+                    } else {
+                               swapCanvas($('holds_box'));
+                               return;
+                    }
+                } else if(res.place_unfillable == 1) {
+                    if( confirm($('hold_place_unfillable_override').innerHTML) ) {
+                        place_anyway = true;
+                    } else {
+                               swapCanvas($('holds_box'));
+                               return;
+                    }
                 }
             }
-            if(!age_protect_override) {
+            if(!place_anyway) {
                        if(res.success != 1) {
 
                     if(!holdArgs.partsSuggestionMade && holdArgs.recordParts && 
index 3b091b6..ff72572 100644 (file)
        <span class='hide_me' id='hold_dup_exists_override'>&common.hold.exists.override;</span>
        <span class='hide_me' id='hold_checked_out_override'>&common.hold.checked_out.override;</span>
        <span class='hide_me' id='hold_age_protected_override'>&common.hold.age_protect.override;</span>
+       <span class='hide_me' id='hold_place_unfillable_override'>&common.hold.place_unfillable.override;</span>
 
        <span id='hold_failed_patron_barred' class='hide_me'>&common.hold.barred;</span>