[open-ils-commits] r18760 - in trunk/Open-ILS: src/perlmods/OpenILS/Application web/js/ui/default/serial/subscription (dbwells)

svn at svn.open-ils.org svn at svn.open-ils.org
Tue Nov 16 16:16:10 EST 2010


Author: dbwells
Date: 2010-11-16 16:16:05 -0500 (Tue, 16 Nov 2010)
New Revision: 18760

Modified:
   trunk/Open-ILS/src/perlmods/OpenILS/Application/Serial.pm
   trunk/Open-ILS/web/js/ui/default/serial/subscription/issuance.js
Log:
Remove deprecated 'all_dists' option for make_predictions(), pass along _build_unit events.


Modified: trunk/Open-ILS/src/perlmods/OpenILS/Application/Serial.pm
===================================================================
--- trunk/Open-ILS/src/perlmods/OpenILS/Application/Serial.pm	2010-11-16 20:11:52 UTC (rev 18759)
+++ trunk/Open-ILS/src/perlmods/OpenILS/Application/Serial.pm	2010-11-16 21:16:05 UTC (rev 18760)
@@ -668,28 +668,24 @@
 
     my $editor = OpenILS::Utils::CStoreEditor->new();
     my $ssub_id = $args->{ssub_id};
-    my $all_dists = $args->{all_dists}; #TODO: this option supports test-level code, will be removed (i.e. always 'true')
     my $mfhd = MFHD->new(MARC::Record->new());
 
     my $ssub = $editor->retrieve_serial_subscription([$ssub_id]);
     my $scaps = $editor->search_serial_caption_and_pattern({ subscription => $ssub_id, active => 't'});
-    my $sdists = $editor->search_serial_distribution( [{ subscription => $ssub->id }, {  flesh => 1,
-              flesh_fields => {sdist => [ qw/ streams / ]}, $all_dists ? () : (limit => 1) }] ); #TODO: 'deleted' support?
+    my $sdists = $editor->search_serial_distribution( [{ subscription => $ssub->id }, { flesh => 1, flesh_fields => {sdist => [ qw/ streams / ]} }] ); #TODO: 'deleted' support?
 
-    if ($all_dists) {
-        my $total_streams = 0;
-        foreach (@$sdists) {
-            $total_streams += scalar(@{$_->streams});
-        }
-        if ($total_streams < 1) {
-            $editor->disconnect;
-            # XXX TODO new event type
-            return new OpenILS::Event(
-                "BAD_PARAMS", note =>
-                    "There are no streams to direct items. Can't predict."
-            );
-        }
+    my $total_streams = 0;
+    foreach (@$sdists) {
+        $total_streams += scalar(@{$_->streams});
     }
+    if ($total_streams < 1) {
+        $editor->disconnect;
+        # XXX TODO new event type
+        return new OpenILS::Event(
+            "BAD_PARAMS", note =>
+                "There are no streams to direct items. Can't predict."
+        );
+    }
 
     unless (@$scaps) {
         $editor->disconnect;
@@ -990,7 +986,12 @@
             my $unit;
             my $sdists = $editor->search_serial_distribution([{"+sstr" => {"id" => $stream_id}}, { "join" => {"sstr" => {}} }]);
             $unit = _build_unit($editor, $sdists->[0], $mode, 0, $barcodes->{$item->id});
-            # TODO: catch events from _build_unit
+            # if _build_unit fails, $unit is an event, so return it
+            if ($U->event_code($unit)) {
+                $editor->rollback;
+                $unit->{"note"} = "Item ID: " . $item->id;
+                return $unit;
+            }
             my $evt =  _create_sunit($editor, $unit);
             return $evt if $evt;
             if ($unit_id == -2) {

Modified: trunk/Open-ILS/web/js/ui/default/serial/subscription/issuance.js
===================================================================
--- trunk/Open-ILS/web/js/ui/default/serial/subscription/issuance.js	2010-11-16 20:11:52 UTC (rev 18759)
+++ trunk/Open-ILS/web/js/ui/default/serial/subscription/issuance.js	2010-11-16 21:16:05 UTC (rev 18760)
@@ -59,7 +59,7 @@
 }
 
 function generate_predictions(fields) {
-    var args = {"ssub_id": sub.id(), "all_dists": true};
+    var args = {"ssub_id": sub.id()};
 
     if (fields.end_how == "date") {
         args.end_date = sub.end_date();



More information about the open-ils-commits mailing list