From 30345ce3aa6f993a7da7049552aa0d0bca4b16ee Mon Sep 17 00:00:00 2001 From: Jessica Smith <12jessicasmith34@gmail.com> Date: Mon, 13 Jan 2025 17:11:58 -0600 Subject: [PATCH] add studio_uuid to booking, make is_home_studio check more concise --- src/otf_api/api.py | 6 ++---- src/otf_api/models/bookings.py | 5 +++++ 2 files changed, 7 insertions(+), 4 deletions(-) diff --git a/src/otf_api/api.py b/src/otf_api/api.py index 7fe785b..82c7ecb 100644 --- a/src/otf_api/api.py +++ b/src/otf_api/api.py @@ -448,10 +448,8 @@ def get_bookings( for booking in data.bookings: if not booking.otf_class: continue - if booking.otf_class.studio.studio_uuid == self.home_studio_uuid: - booking.is_home_studio = True - else: - booking.is_home_studio = False + + booking.is_home_studio = booking.studio_uuid == self.home_studio_uuid if exclude_cancelled: data.bookings = [b for b in data.bookings if b.status != models.BookingStatus.Cancelled] diff --git a/src/otf_api/models/bookings.py b/src/otf_api/models/bookings.py index 75d8c0e..98d0edb 100644 --- a/src/otf_api/models/bookings.py +++ b/src/otf_api/models/bookings.py @@ -122,6 +122,11 @@ class Booking(OtfItemBase): studio_id: int = Field(alias="studioId", exclude=True, repr=False, description="Not used by API") updated_by: str = Field(alias="updatedBy", exclude=True, repr=False) + @property + def studio_uuid(self) -> str: + """Shortcut to get the studio UUID""" + return self.otf_class.studio.studio_uuid + @property def class_uuid(self) -> str: """Shortcut to get the class UUID"""