refactors
This commit is contained in:
parent
4e1a339432
commit
82c4d0168e
28 changed files with 1042 additions and 782 deletions
47
backend/schemas/availability.py
Normal file
47
backend/schemas/availability.py
Normal file
|
|
@ -0,0 +1,47 @@
|
|||
from datetime import date, time
|
||||
|
||||
from pydantic import BaseModel, field_validator
|
||||
|
||||
|
||||
class TimeSlot(BaseModel):
|
||||
"""A single time slot (start and end time)."""
|
||||
|
||||
start_time: time
|
||||
end_time: time
|
||||
|
||||
@field_validator("start_time", "end_time")
|
||||
@classmethod
|
||||
def validate_15min_boundary(cls, v: time) -> time:
|
||||
"""Ensure times are on 15-minute boundaries."""
|
||||
if v.minute not in (0, 15, 30, 45):
|
||||
raise ValueError("Time must be on 15-minute boundary (:00, :15, :30, :45)")
|
||||
if v.second != 0 or v.microsecond != 0:
|
||||
raise ValueError("Time must not have seconds or microseconds")
|
||||
return v
|
||||
|
||||
|
||||
class AvailabilityDay(BaseModel):
|
||||
"""Availability for a single day."""
|
||||
|
||||
date: date
|
||||
slots: list[TimeSlot]
|
||||
|
||||
|
||||
class AvailabilityResponse(BaseModel):
|
||||
"""Response model for availability query."""
|
||||
|
||||
days: list[AvailabilityDay]
|
||||
|
||||
|
||||
class SetAvailabilityRequest(BaseModel):
|
||||
"""Request to set availability for a specific date."""
|
||||
|
||||
date: date
|
||||
slots: list[TimeSlot]
|
||||
|
||||
|
||||
class CopyAvailabilityRequest(BaseModel):
|
||||
"""Request to copy availability from one day to others."""
|
||||
|
||||
source_date: date
|
||||
target_dates: list[date]
|
||||
Loading…
Add table
Add a link
Reference in a new issue