Skip to content

Commit 646cc08

Browse files
committed
Merge branch 'devel'
2 parents d632c76 + 0d9630d commit 646cc08

File tree

3 files changed

+34
-8
lines changed

3 files changed

+34
-8
lines changed

CHANGELOG.md

+14-5
Original file line numberDiff line numberDiff line change
@@ -4,20 +4,29 @@
44

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

7+
## 3.3.0
8+
9+
### Added
10+
11+
- `pyppms.ppms.get_running_sheet()` now has an optional parameter `localisation`
12+
(defaulting to an empty `str`) that will be passed to the call to
13+
`pyppms.ppms.get_systems_matching()`, allowing to restrict the runningsheet to
14+
systems of a given "room".
15+
716
## 3.2.1
817

918
### Fixed
1019

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

1625
## 3.2.0
1726

1827
### Added
1928

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

2332
### Changed

src/pyppms/booking.py

+1
Original file line numberDiff line numberDiff line change
@@ -66,6 +66,7 @@ def __init__(self, text, booking_type, system_id):
6666

6767
log.trace(str(self))
6868

69+
# FIXME: date is of type datetime.datetime, NOT datetime.date !!!
6970
@classmethod
7071
def from_runningsheet(cls, entry, system_id, username, date):
7172
"""Alternative constructor using a (parsed) getrunningsheet response.

src/pyppms/ppms.py

+19-3
Original file line numberDiff line numberDiff line change
@@ -564,7 +564,9 @@ def get_next_booking(self, system_id):
564564
"""Wrapper for `get_booking()` with 'booking_type' set to 'next'."""
565565
return self.get_booking(system_id, "next")
566566

567-
def get_running_sheet(self, core_facility_ref, date, ignore_uncached_users=False):
567+
def get_running_sheet(
568+
self, core_facility_ref, date, ignore_uncached_users=False, localisation=""
569+
):
568570
"""Get the running sheet for a specific day on the given facility.
569571
570572
The so-called "running-sheet" consists of all bookings / reservations of
@@ -585,6 +587,9 @@ def get_running_sheet(self, core_facility_ref, date, ignore_uncached_users=False
585587
ignore_uncached_users : bool, optional
586588
If set to `True` any booking for a user that is not present in the instance
587589
attribute `fullname_mapping` will be ignored in the resulting list.
590+
localisation : str, optional
591+
If given, the runningsheet will be limited to systems where the
592+
`localisation` (~"room") field matches the given value.
588593
589594
Returns
590595
-------
@@ -628,8 +633,19 @@ def get_running_sheet(self, core_facility_ref, date, ignore_uncached_users=False
628633
f"Booking for user '{self.fullname_mapping[full]}' ({full}) found"
629634
)
630635
system_name = entry["Object"]
631-
system_ids = self.get_systems_matching("", [system_name])
632-
if len(system_ids) != 1:
636+
# FIXME: add a test with one system name being a subset of another system
637+
# (this will result in more than one result and should be fixed e.g. by
638+
# adding an optional parameter "exact" to get_systems_matching() or
639+
# similar)
640+
system_ids = self.get_systems_matching(localisation, [system_name])
641+
if len(system_ids) < 1:
642+
if localisation:
643+
log.debug(f"Given criteria return zero systems for [{system_name}]")
644+
else:
645+
log.warning(f"No systems matching criteria for [{system_name}]")
646+
continue
647+
648+
if len(system_ids) > 1:
633649
# NOTE: more than one result should not happen as PPMS doesn't allow for
634650
# multiple systems having the same name - no result might happen though!
635651
log.error("Ignoring booking for unknown system [{}]", system_name)

0 commit comments

Comments
 (0)