Skip to content

Commit

Permalink
circulation: adapt reroils
Browse files Browse the repository at this point in the history
Adapts reroils after the upgrade to invenio-circulation v1.0.0a21.

The two transitions ItemOnLoanToItemReturned and ItemOnLoanToItemReturned are
temporarily updated and inserted into reroils until a fix for the issue
inveniosoftware/invenio-circulation#127 is available.

This PR expects the fix for the ITEM_AT_DESK problem in the current version
of invenio-circulation.

Some timezone units testing are disabled until a fix is given in a later PR.

Co-Authored-by: Aly Badr <aly.badr@rero.ch>
  • Loading branch information
Aly Badr committed Apr 26, 2020
1 parent 69f20a1 commit 722005d
Show file tree
Hide file tree
Showing 21 changed files with 385 additions and 241 deletions.
3 changes: 2 additions & 1 deletion Pipfile
Original file line number Diff line number Diff line change
Expand Up @@ -38,7 +38,8 @@ Babel = ">=2.4.0"
Flask-BabelEx = ">=0.9.3"
## Third party invenio modules used by RERO ILS
invenio-oaiharvester = {editable = true, ref = "v1.0.0a4", git = "https://github.com/inveniosoftware/invenio-oaiharvester.git"}
invenio-circulation = {editable = true, ref = "v1.0.0a21", git = "https://github.com/inveniosoftware/invenio-circulation.git"}
# invenio-circulation = {editable = true, ref = "v1.0.0a21", git = "https://github.com/inveniosoftware/invenio-circulation.git"}
invenio-circulation = {editable = true, ref = "item_at_desk_temp", git = "https://github.com/rero/invenio-circulation.git"}
## Invenio 3.2.1 base modules used by RERO ILS
# same as invenio metadata extras without invenio-search-ui
invenio-indexer = ">=1.1.1,<1.2.0"
Expand Down
78 changes: 35 additions & 43 deletions Pipfile.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

21 changes: 14 additions & 7 deletions rero_ils/config.py
Original file line number Diff line number Diff line change
Expand Up @@ -57,6 +57,7 @@
from .modules.items.api import Item
from .modules.items.permissions import can_create_item_factory, \
can_update_delete_item_factory
from .modules.items.utils import item_exists, item_location_retriever
from .modules.libraries.api import Library
from .modules.libraries.permissions import can_update_library_factory
from .modules.loans.api import Loan
Expand All @@ -66,6 +67,7 @@
ItemOnLoanToItemReturned
from .modules.loans.utils import can_be_requested, get_default_loan_duration, \
get_extension_params, is_item_available_for_checkout, \
loan_build_document_ref, loan_build_item_ref, loan_build_patron_ref, \
loan_satisfy_circ_policies
from .modules.locations.api import Location
from .modules.locations.permissions import can_create_location_factory, \
Expand Down Expand Up @@ -1586,18 +1588,20 @@ def _(x):
}

#: Invenio circulation configuration.
CIRCULATION_ITEM_EXISTS = Item.get_record_by_pid
CIRCULATION_ITEM_EXISTS = item_exists
CIRCULATION_PATRON_EXISTS = Patron.get_record_by_pid

CIRCULATION_ITEM_LOCATION_RETRIEVER = Item.item_location_retriever
CIRCULATION_ITEM_LOCATION_RETRIEVER = item_location_retriever
CIRCULATION_DOCUMENT_RETRIEVER_FROM_ITEM = \
Item.get_document_pid_by_item_pid
Item.get_document_pid_by_item_pid_object
CIRCULATION_ITEMS_RETRIEVER_FROM_DOCUMENT = Item.get_items_pid_by_document_pid

CIRCULATION_DOCUMENT_EXISTS = Document.get_record_by_pid
CIRCULATION_ITEM_REF_BUILDER = Loan.loan_build_item_ref
CIRCULATION_PATRON_REF_BUILDER = Loan.loan_build_patron_ref
CIRCULATION_DOCUMENT_REF_BUILDER = Loan.loan_build_document_ref

CIRCULATION_ITEM_REF_BUILDER = loan_build_item_ref
CIRCULATION_PATRON_REF_BUILDER = loan_build_patron_ref
CIRCULATION_DOCUMENT_REF_BUILDER = loan_build_document_ref

CIRCULATION_TRANSACTION_LOCATION_VALIDATOR = \
Location.transaction_location_validator
CIRCULATION_TRANSACTION_USER_VALIDATOR = \
Expand Down Expand Up @@ -1673,7 +1677,10 @@ def _(x):
dict(dest='CANCELLED', trigger='cancel', transition=ToCancelled)
],
'ITEM_IN_TRANSIT_FOR_PICKUP': [
dict(dest='ITEM_AT_DESK', trigger='receive'),
dict(
dest='ITEM_AT_DESK',
trigger='receive'
),
dict(dest='CANCELLED', trigger='cancel', transition=ToCancelled)
],
'ITEM_ON_LOAN': [
Expand Down
4 changes: 2 additions & 2 deletions rero_ils/modules/documents/views.py
Original file line number Diff line number Diff line change
Expand Up @@ -40,6 +40,7 @@
title_variant_format_text
from ..holdings.api import Holding
from ..items.api import Item, ItemStatus
from ..items.utils import item_pid_to_object
from ..libraries.api import Library
from ..loans.api import Loan
from ..loans.utils import can_be_requested
Expand Down Expand Up @@ -208,8 +209,7 @@ def can_request(item):
item.get_library().replace_refs()['organisation']['pid']:
# Complete metadata before Loan creation
loan_metadata = dict(item)
if 'item_pid' not in loan_metadata:
loan_metadata['item_pid'] = item.pid
loan_metadata['item_pid'] = item_pid_to_object(item.pid)
if 'patron_pid' not in loan_metadata:
loan_metadata['patron_pid'] = patron.pid
# Create "virtual" Loan (not registered)
Expand Down
Loading

0 comments on commit 722005d

Please sign in to comment.