Skip to content

Commit

Permalink
circulation ui: check if item or patron is in same organisation
Browse files Browse the repository at this point in the history
* Closes rero#377

Co-Authored-by: Bertrand Zuchuat <bertrand.zuchuat@rero.ch>
  • Loading branch information
Garfield-fr authored and jma committed Sep 2, 2019
1 parent 4ae44d8 commit 5746dd1
Show file tree
Hide file tree
Showing 2 changed files with 14 additions and 2 deletions.
5 changes: 5 additions & 0 deletions rero_ils/modules/items/api.py
Original file line number Diff line number Diff line change
Expand Up @@ -285,6 +285,11 @@ def dumps_for_circulation(self):
location = Location.get_record_by_pid(item['location']['pid'])
loc_data = location.dumps()
data['location']['name'] = loc_data['name']
organisation = self.get_organisation()
data['location']['organisation'] = {
'pid': organisation.get('pid'),
'name': organisation.get('name')
}
data['actions'] = list(self.actions)
data['available'] = self.available
# data['number_of_requests'] = self.number_of_requests()
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -111,10 +111,13 @@ export class MainCheckinCheckoutComponent implements OnInit, NoPendingChange {
automaticCheckinCheckout(item_barcode) {
this.itemsService.automaticCheckin(item_barcode).subscribe(item => {
// TODO: remove this when policy will be in place
if (item === null) {
if (
item === null ||
item.location.organisation.pid !== this.loggedUser.library.organisation.pid
) {
this.toastService.warning(_('item not found!'), _('checkin'));
return;
}
}
if (item.loan) {
this.getPatronInfo(item.loan.patron_pid);
}
Expand Down Expand Up @@ -191,6 +194,10 @@ export class MainCheckinCheckoutComponent implements OnInit, NoPendingChange {
if (barcode) {
this.userService.getPatron(barcode).subscribe(
(patron) => {
if (patron !== null && patron.organisation.pid !== this.loggedUser.library.organisation.pid) {
this.toastService.warning(_('patron not found!'), _('checkin'));
return;
}
if (patron === null) {
const newItem = this.items.find(item => item.barcode === barcode);
if (newItem) {
Expand Down

0 comments on commit 5746dd1

Please sign in to comment.