FAQ | This is a LIVE service | Changelog

GitLab has been upgraded to 13.10.3. See what's new in the Changelog.

Commit 0e358d71 authored by Robin Goodall's avatar Robin Goodall 💬

Booked_by exclusion/inclusion filter needs to be a list

parent 50b100f5
Pipeline #40613 passed with stages
in 6 minutes and 42 seconds
......@@ -329,11 +329,11 @@ def op_get_room_bookings(start=None, end=None):
bookings = _get_bookings(start, end)
# booked by user to use in filter
booked_by = state.get('booker.booked_by', 'essm-sync')
booked_by = _get_booked_by_list()
# filter to those *not* booked by booked_by
bookings = [b for b in bookings if (
'BookedBy' not in b or 'Id' not in b['BookedBy'] or
b['BookedBy']['Id'] != booked_by)]
b['BookedBy']['Id'] not in booked_by)]
LOG.info(f'Bookings not booked by {booked_by}: {len(bookings)}')
state.set('booker.roombookings', bookings)
......@@ -357,15 +357,27 @@ def op_get_events(start=None, end=None):
bookings = _get_bookings(start, end)
# booked by user to use in filter
booked_by = state.get('booker.booked_by', 'essm-sync')
booked_by = _get_booked_by_list()
# filter to *only* those booked by booked_by
bookings = [b for b in bookings if (
'BookedBy' in b and 'Id' in b['BookedBy'] and
b['BookedBy']['Id'] == booked_by)]
b['BookedBy']['Id'] in booked_by)]
LOG.info(f'Bookings booked by {booked_by}: {len(bookings)}')
state.set('booker.events', bookings)
def _get_booked_by_list():
"""
Get 'booker.booked_by' setting (defaulting to 'essm-sync') forcing to a list
if only a single value is present.
"""
booked_by = state.get('booker.booked_by', 'essm-sync')
if not isinstance(booked_by, list):
return [booked_by]
return booked_by
def _get_termtime_timeframe_dates():
# which timeframe to use
tf_code = state.get('termtime.timeframe', 'All Year')
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment