Skip to content

Commit

Permalink
add studio_uuid to booking, make is_home_studio check more concise
Browse files Browse the repository at this point in the history
  • Loading branch information
NodeJSmith committed Jan 13, 2025
1 parent 7c1c6de commit 30345ce
Show file tree
Hide file tree
Showing 2 changed files with 7 additions and 4 deletions.
6 changes: 2 additions & 4 deletions src/otf_api/api.py
Original file line number Diff line number Diff line change
Expand Up @@ -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]
Expand Down
5 changes: 5 additions & 0 deletions src/otf_api/models/bookings.py
Original file line number Diff line number Diff line change
Expand Up @@ -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"""
Expand Down

0 comments on commit 30345ce

Please sign in to comment.