Skip to content

Commit

Permalink
improve str rep of classes and bookings
Browse files Browse the repository at this point in the history
  • Loading branch information
NodeJSmith committed Jan 8, 2025
1 parent ac80f8c commit 9b1273a
Show file tree
Hide file tree
Showing 2 changed files with 11 additions and 0 deletions.
6 changes: 6 additions & 0 deletions src/otf_api/models/bookings.py
Original file line number Diff line number Diff line change
Expand Up @@ -100,6 +100,12 @@ class Booking(OtfItemBase):
otf_class: OtfClass = Field(alias="class")
is_home_studio: bool | None = Field(None, description="Custom helper field to determine if at home studio")

def __str__(self) -> str:
class_starts_at_str = self.otf_class.starts_at_local.strftime("%Y-%m-%d %H:%M:%S")
class_name = self.otf_class.name
coach_name = self.otf_class.coach.name
return f"{class_starts_at_str} {class_name} with {coach_name}"


class BookingList(OtfItemBase):
bookings: list[Booking]
Expand Down
5 changes: 5 additions & 0 deletions src/otf_api/models/classes.py
Original file line number Diff line number Diff line change
Expand Up @@ -50,6 +50,11 @@ class OtfClass(OtfItemBase, OtfClassTimeMixin):
is_home_studio: bool | None = Field(None, description="Custom helper field to determine if at home studio")
is_booked: bool | None = Field(None, description="Custom helper field to determine if class is already booked")

def __str__(self) -> str:
starts_at_str = self.starts_at_local.strftime("%Y-%m-%d %H:%M:%S")
coach_name = self.coach.first_name
return f"{starts_at_str} {self.name} with {coach_name}"

@property
def has_availability(self) -> bool:
return not self.full
Expand Down

0 comments on commit 9b1273a

Please sign in to comment.