Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

circulation: masked item are not available #2015

Merged
merged 1 commit into from
Jun 11, 2021
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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 considered as unavailable.
"""
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