Skip to content

Commit

Permalink
loan: add location pickup name on circulation
Browse files Browse the repository at this point in the history
* Adds the location pickup_name field on circulation information.
* Closes rero#3433.

Co-Authored-by: Bertrand Zuchuat <[email protected]>
  • Loading branch information
Garfield-fr committed Oct 2, 2023
1 parent 6106294 commit 8355f1e
Show file tree
Hide file tree
Showing 3 changed files with 10 additions and 5 deletions.
2 changes: 1 addition & 1 deletion rero_ils/modules/loans/api.py
Original file line number Diff line number Diff line change
Expand Up @@ -424,7 +424,7 @@ def item_type_by_pid(pid, known_ittys):
patron_data = patron_by_pid(loan_data['patron_pid'],
patrons)
loan_data['patron'] = {
'barcode': patron_data['patron']['barcode'],
'barcode': patron_data['patron']['barcode'][0],
'name': f'{patron_data["last_name"]}, '
f'{patron_data["first_name"]}'
}
Expand Down
7 changes: 3 additions & 4 deletions rero_ils/modules/loans/dumpers.py
Original file line number Diff line number Diff line change
Expand Up @@ -47,14 +47,13 @@ def dump(self, record, data):
data['patron']['name'] = ', '.join((
ptrn_data.last_name, ptrn_data.first_name))

# only for pending requests
if record.get('pickup_location_pid') \
and record.get('state') == LoanState.PENDING:
if record.get('pickup_location_pid'):
location = Location.get_record_by_pid(
record.get('pickup_location_pid'))
data['pickup_location'] = {
'name': location.get('name'),
'library_name': location.get_library().get('name')
'library_name': location.get_library().get('name'),
'pickup_name': location.pickup_name
}

# Always add item destination readable information if item state is
Expand Down
6 changes: 6 additions & 0 deletions rero_ils/modules/locations/api.py
Original file line number Diff line number Diff line change
Expand Up @@ -211,6 +211,12 @@ def restrict_pickup_to(self):
for restrict_pickup_to in self.get('restrict_pickup_to', [])
]

@property
def pickup_name(self):
"""Get pickup name for location."""
return self['pickup_name'] if 'pickup_name' in self \
else f"{self.library['code']}: {self['name']}"

@classmethod
def can_request(cls, record, **kwargs):
"""Check if a record can be requested regarding its location.
Expand Down

0 comments on commit 8355f1e

Please sign in to comment.