Skip to content

Commit

Permalink
Merge branch 'devel'
Browse files Browse the repository at this point in the history
  • Loading branch information
ehrenfeu committed Jul 7, 2023
2 parents d632c76 + 0d9630d commit 646cc08
Show file tree
Hide file tree
Showing 3 changed files with 34 additions and 8 deletions.
19 changes: 14 additions & 5 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -4,20 +4,29 @@

NOTE: potentially breaking changes are flagged with a 🧨 symbol.

## 3.3.0

### Added

- `pyppms.ppms.get_running_sheet()` now has an optional parameter `localisation`
(defaulting to an empty `str`) that will be passed to the call to
`pyppms.ppms.get_systems_matching()`, allowing to restrict the runningsheet to
systems of a given "room".

## 3.2.1

### Fixed

- `pyppms.booking.PpmsBooking.endtime_fromstr()` contained a bug where the
end time of a booking finishing at midnight got wrongly assigning it to the
*start* of the given day instead of the end. This is now fixed by setting the
end time to the start of the following day.
- 🕛🌃 end time: `pyppms.booking.PpmsBooking.endtime_fromstr()` contained a bug
where the end time of a booking finishing at midnight got wrongly assigned to
the *start* of the given day (instead of the end). This is now fixed by
setting the end time to the start of the following day.

## 3.2.0

### Added

- `pyppms.booking.PpmsBooking.last_served_from_cache` has been added to indicate
- `pyppms.ppms.PpmsConnection.last_served_from_cache` has been added to indicate
if the last request was served from the cache or on-line.

### Changed
Expand Down
1 change: 1 addition & 0 deletions src/pyppms/booking.py
Original file line number Diff line number Diff line change
Expand Up @@ -66,6 +66,7 @@ def __init__(self, text, booking_type, system_id):

log.trace(str(self))

# FIXME: date is of type datetime.datetime, NOT datetime.date !!!
@classmethod
def from_runningsheet(cls, entry, system_id, username, date):
"""Alternative constructor using a (parsed) getrunningsheet response.
Expand Down
22 changes: 19 additions & 3 deletions src/pyppms/ppms.py
Original file line number Diff line number Diff line change
Expand Up @@ -564,7 +564,9 @@ def get_next_booking(self, system_id):
"""Wrapper for `get_booking()` with 'booking_type' set to 'next'."""
return self.get_booking(system_id, "next")

def get_running_sheet(self, core_facility_ref, date, ignore_uncached_users=False):
def get_running_sheet(
self, core_facility_ref, date, ignore_uncached_users=False, localisation=""
):
"""Get the running sheet for a specific day on the given facility.
The so-called "running-sheet" consists of all bookings / reservations of
Expand All @@ -585,6 +587,9 @@ def get_running_sheet(self, core_facility_ref, date, ignore_uncached_users=False
ignore_uncached_users : bool, optional
If set to `True` any booking for a user that is not present in the instance
attribute `fullname_mapping` will be ignored in the resulting list.
localisation : str, optional
If given, the runningsheet will be limited to systems where the
`localisation` (~"room") field matches the given value.
Returns
-------
Expand Down Expand Up @@ -628,8 +633,19 @@ def get_running_sheet(self, core_facility_ref, date, ignore_uncached_users=False
f"Booking for user '{self.fullname_mapping[full]}' ({full}) found"
)
system_name = entry["Object"]
system_ids = self.get_systems_matching("", [system_name])
if len(system_ids) != 1:
# FIXME: add a test with one system name being a subset of another system
# (this will result in more than one result and should be fixed e.g. by
# adding an optional parameter "exact" to get_systems_matching() or
# similar)
system_ids = self.get_systems_matching(localisation, [system_name])
if len(system_ids) < 1:
if localisation:
log.debug(f"Given criteria return zero systems for [{system_name}]")
else:
log.warning(f"No systems matching criteria for [{system_name}]")
continue

if len(system_ids) > 1:
# NOTE: more than one result should not happen as PPMS doesn't allow for
# multiple systems having the same name - no result might happen though!
log.error("Ignoring booking for unknown system [{}]", system_name)
Expand Down

0 comments on commit 646cc08

Please sign in to comment.