Skip to content

Commit

Permalink
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Circulation: integration of invenio-circulation APIs
Browse files Browse the repository at this point in the history
 * NEW makes invenio circ APIs available

Signed-off-by: Aly Badr <aly.badr@rero.ch>
Aly Badr committed Nov 7, 2018
1 parent 2287e67 commit 44649b7
Showing 6 changed files with 349 additions and 223 deletions.
2 changes: 1 addition & 1 deletion Pipfile
Original file line number Diff line number Diff line change
@@ -34,7 +34,7 @@ pytest-pep8 = ">=1.0.6"
pytest-random-order = ">=0.5.4"
pytest-runner = ">=3.0.0,<5"
transifex-client = ">=0.12.5"
requests = ">=2.19.1"
requests = ">=2.20.0"
rero-ils = {editable = true, path = "."}

[requires]
28 changes: 16 additions & 12 deletions Pipfile.lock

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

1 change: 1 addition & 0 deletions requirements-devel.txt
Original file line number Diff line number Diff line change
@@ -27,6 +27,7 @@
# base bundle
-e git+https://github.com/inveniosoftware/invenio-admin.git#egg=invenio-admin
-e git+git://github.com/inveniosoftware/invenio-assets.git#egg=invenio-assets
-e git+git://github.com/inveniosoftware/invenio-circulation.git#egg=invenio-circulation
-e git+git://github.com/inveniosoftware/invenio-formatter.git#egg=invenio-formatter
-e git+git://github.com/inveniosoftware/invenio-logging.git#egg=invenio-logging
-e git+https://github.com/inveniosoftware/invenio-mail.git#egg=invenio-mail
512 changes: 302 additions & 210 deletions rero_ils/config.py

Large diffs are not rendered by default.

19 changes: 19 additions & 0 deletions rero_ils/modules/documents_items/api.py
Original file line number Diff line number Diff line change
@@ -134,3 +134,22 @@ def get_document_by_itemid(cls, id_, with_deleted=False):
return super(DocumentsWithItems, cls).get_record_by_elementid(
id_, with_deleted
)

@classmethod
def document_retriever(cls, item_pid, **kwargs):
"""Retrieve document pid from item pid."""
document_pid = ''
if Item.get_record_by_pid(item_pid):
id = Item.get_record_by_pid(item_pid).id
document_pid = cls.get_document_by_itemid(id).pid
return document_pid

@classmethod
def items_retriever(cls, document_pid):
"""Retrieve item pids by document pid."""
item_pids = []
if cls.get_record_by_pid(document_pid):
document = cls.get_record_by_pid(document_pid)
for item in document.itemslist:
item_pids.append(item.get('pid'))
return item_pids
10 changes: 10 additions & 0 deletions rero_ils/modules/items/api.py
Original file line number Diff line number Diff line change
@@ -527,3 +527,13 @@ def loaned_to_patron(self, patron_barcode):
if holding['patron_barcode'] == patron_barcode:
return True
return False

@classmethod
def item_location_retriever(cls, item_pid, **kwargs):
"""Get item location."""
location_pid = ''
if cls.get_record_by_pid(item_pid):
item = cls.get_record_by_pid(item_pid)
if item.get('location_pid'):
location_pid = item.get('location_pid')
return location_pid

0 comments on commit 44649b7

Please sign in to comment.