Skip to content

Commit

Permalink
circulation: masked item are not available
Browse files Browse the repository at this point in the history
Masked items must be considerate as not available for circulation
operation and public view.

Co-Authored-by: Renaud Michotte <[email protected]>
  • Loading branch information
zannkukai committed Jun 9, 2021
1 parent 5573032 commit ca7d2bb
Show file tree
Hide file tree
Showing 2 changed files with 10 additions and 0 deletions.
3 changes: 3 additions & 0 deletions rero_ils/modules/items/api/circulation.py
Original file line number Diff line number Diff line change
Expand Up @@ -1241,7 +1241,10 @@ def available(self):
An item is 'available' if there are no related request/active_loan and
if the related circulation category doesn't specify a negative
availability.
All masked items are considerate as not available.
"""
if self.get('_masked', False):
return False
if self.item_has_active_loan_or_request() > 0:
return False
if self.circulation_category.get('negative_availability'):
Expand Down
7 changes: 7 additions & 0 deletions tests/api/test_availability.py
Original file line number Diff line number Diff line change
Expand Up @@ -287,6 +287,13 @@ def test_item_holding_document_availability(
assert document_availability_status(
client, document.pid, librarian_martigny.user)

# masked item isn't available
item['_masked'] = True
item = item.update(item, dbcommit=True, reindex=True)
assert not item.available
del item['_masked']
item.update(item, dbcommit=True, reindex=True)

# test can not request item already checked out to patron
res = client.get(
url_for(
Expand Down

0 comments on commit ca7d2bb

Please sign in to comment.