Skip to content

Commit 3b595d2

Browse files
committed
loans: fix requested items dump
Dumping of a requested item fails when nor item nor holding hasn't any call numbers. Co-Authored-by: Renaud Michotte <[email protected]>
1 parent a35fc49 commit 3b595d2

File tree

1 file changed

+6
-6
lines changed

1 file changed

+6
-6
lines changed

rero_ils/modules/loans/api.py

+6-6
Original file line numberDiff line numberDiff line change
@@ -340,7 +340,7 @@ def patron_by_pid(pid, known_patrons):
340340
hit = next(iter(results or []), None)
341341
if hit:
342342
known_patrons[pid] = hit.to_dict()
343-
return known_patrons[pid]
343+
return known_patrons.get(pid, {})
344344

345345
def location_by_pid(pid, known_locations):
346346
"""Get location by pid.
@@ -359,7 +359,7 @@ def location_by_pid(pid, known_locations):
359359
if hit:
360360
data = hit.to_dict()
361361
known_locations[pid] = {k: v for k, v in data.items() if v}
362-
return known_locations[pid]
362+
return known_locations.get(pid, {})
363363

364364
def library_name_by_pid(pid, known_libraries):
365365
"""Get library name by pid.
@@ -376,7 +376,7 @@ def library_name_by_pid(pid, known_libraries):
376376
hit = next(iter(results or []), None)
377377
if hit:
378378
known_libraries[pid] = hit.name
379-
return known_libraries[pid]
379+
return known_libraries.get(pid, {})
380380

381381
def holding_by_pid(pid, known_holdings):
382382
"""Get holdings by pid.
@@ -394,7 +394,7 @@ def holding_by_pid(pid, known_holdings):
394394
hit = next(iter(results or []), None)
395395
if hit:
396396
known_holdings[pid] = hit.to_dict()
397-
return known_holdings[pid]
397+
return known_holdings.get(pid, {})
398398

399399
def item_by_pid(pid, known_items):
400400
"""Get item by pid.
@@ -412,7 +412,7 @@ def item_by_pid(pid, known_items):
412412
.source(includes=fields)\
413413
.execute()
414414
known_items[pid] = next(iter(results or []), None)
415-
return known_items[pid]
415+
return known_items.get(pid, {})
416416

417417
def item_type_by_pid(pid, known_ittys):
418418
"""Get item type by pid.
@@ -427,7 +427,7 @@ def item_type_by_pid(pid, known_ittys):
427427
.filter('term', negative_availability=False)\
428428
.execute()
429429
known_ittys[pid] = next(iter(results or []), None)
430-
return known_ittys[pid]
430+
return known_ittys.get(pid, {})
431431

432432
metadata = []
433433
item_pids = []

0 commit comments

Comments
 (0)