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 #3433.

Co-Authored-by: Bertrand Zuchuat <[email protected]>
  • Loading branch information
Garfield-fr committed Sep 28, 2023
1 parent 9dd4c2f commit 9dbe6b8
Show file tree
Hide file tree
Showing 2 changed files with 11 additions and 3 deletions.
8 changes: 5 additions & 3 deletions rero_ils/modules/loans/dumpers.py
Original file line number Diff line number Diff line change
Expand Up @@ -47,14 +47,16 @@ def dump(self, record, data):
data['patron']['name'] = ', '.join((
ptrn_data.last_name, ptrn_data.first_name))

# only for pending requests
# only for pending requests and item at desk
if record.get('pickup_location_pid') \
and record.get('state') == LoanState.PENDING:
and record.get('state') in [
LoanState.PENDING, LoanState.ITEM_AT_DESK]:
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 9dbe6b8

Please sign in to comment.