Skip to content

Commit

Permalink
loan: update loan
Browse files Browse the repository at this point in the history
* Adds route to update loan.
* Adds update_loan method in api.

Co-Authored-by: Alicia Zangger <alicia.zangger@rero.ch>
  • Loading branch information
Alicia Zangger committed Apr 15, 2020
1 parent b8faefb commit b2291b2
Show file tree
Hide file tree
Showing 2 changed files with 20 additions and 0 deletions.
11 changes: 11 additions & 0 deletions rero_ils/modules/items/api.py
Original file line number Diff line number Diff line change
Expand Up @@ -894,6 +894,17 @@ def checkout(self, current_loan, **kwargs):
actions.update({LoanAction.CHECKOUT: loan})
return self, actions


@add_loans_parameters_and_flush_indexes
def update_loan(self, current_loan, **kwargs):
"""Update a loan."""
loan = Loan.get_record_by_pid(kwargs.get('pid'))
if kwargs.get("pickup_location_pid"):
data = {'pickup_location_pid': kwargs.get("pickup_location_pid")}
loan.update(data, dbcommit=True, reindex=True)
return self, { }


@add_loans_parameters_and_flush_indexes
def cancel_loan(self, current_loan, **kwargs):
"""Cancel a given item loan for a patron."""
Expand Down
9 changes: 9 additions & 0 deletions rero_ils/modules/items/api_views.py
Original file line number Diff line number Diff line change
Expand Up @@ -167,6 +167,15 @@ def cancel_loan(item, params):
return item.cancel_loan(**params)


@api_blueprint.route("/update_loan", methods=['POST'])
@check_authentication
@jsonify_action
def update_loan(item, params):
"""HTTP request for cancel action."""
# print('update', item, params)
return item.update_loan(**params)


@api_blueprint.route("/lose", methods=['POST'])
@check_authentication
@jsonify_action
Expand Down

0 comments on commit b2291b2

Please sign in to comment.