Skip to content

Commit

Permalink
loans: fix requested items dump
Browse files Browse the repository at this point in the history
Dumping of a requested item fails when nor item nor holding hasn't any
call numbers.

Co-Authored-by: Renaud Michotte <renaud.michotte@gmail.com>
  • Loading branch information
zannkukai committed Sep 14, 2021
1 parent a35fc49 commit 3b595d2
Showing 1 changed file with 6 additions and 6 deletions.
12 changes: 6 additions & 6 deletions rero_ils/modules/loans/api.py
Original file line number Diff line number Diff line change
Expand Up @@ -340,7 +340,7 @@ def patron_by_pid(pid, known_patrons):
hit = next(iter(results or []), None)
if hit:
known_patrons[pid] = hit.to_dict()
return known_patrons[pid]
return known_patrons.get(pid, {})

def location_by_pid(pid, known_locations):
"""Get location by pid.
Expand All @@ -359,7 +359,7 @@ def location_by_pid(pid, known_locations):
if hit:
data = hit.to_dict()
known_locations[pid] = {k: v for k, v in data.items() if v}
return known_locations[pid]
return known_locations.get(pid, {})

def library_name_by_pid(pid, known_libraries):
"""Get library name by pid.
Expand All @@ -376,7 +376,7 @@ def library_name_by_pid(pid, known_libraries):
hit = next(iter(results or []), None)
if hit:
known_libraries[pid] = hit.name
return known_libraries[pid]
return known_libraries.get(pid, {})

def holding_by_pid(pid, known_holdings):
"""Get holdings by pid.
Expand All @@ -394,7 +394,7 @@ def holding_by_pid(pid, known_holdings):
hit = next(iter(results or []), None)
if hit:
known_holdings[pid] = hit.to_dict()
return known_holdings[pid]
return known_holdings.get(pid, {})

def item_by_pid(pid, known_items):
"""Get item by pid.
Expand All @@ -412,7 +412,7 @@ def item_by_pid(pid, known_items):
.source(includes=fields)\
.execute()
known_items[pid] = next(iter(results or []), None)
return known_items[pid]
return known_items.get(pid, {})

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

metadata = []
item_pids = []
Expand Down

0 comments on commit 3b595d2

Please sign in to comment.