Restructured the schemas correctly now too.

Signed-off-by: Cliff Hill <xlorep@darkhelm.org>
This commit is contained in:
2025-08-22 22:45:02 -04:00
parent 428b9835e1
commit a1a435c7c1
6 changed files with 114 additions and 97 deletions

View File

@@ -1,97 +0,0 @@
"""Pydantic schemas for the Numinar coding project backend."""
from datetime import datetime
from typing import Optional
from pydantic import BaseModel
from pydantic import ConfigDict
class UserBase(BaseModel):
"""Base schema for User."""
email: str
name: Optional[str] = None
class UserCreate(UserBase):
"""Schema for creating a new User."""
model_config = ConfigDict(from_attributes=True)
class UserResponse(UserBase):
"""Response schema for User, including ID."""
id: int
model_config = ConfigDict(from_attributes=True)
class RoomBase(BaseModel):
"""Base schema for Room."""
name: str
location: Optional[str] = None
equipment: Optional[str] = None
capacity: int = 1
class RoomCreate(RoomBase):
"""Schema for creating a new Room."""
model_config = ConfigDict(from_attributes=True)
class RoomResponse(RoomBase):
"""Response schema for Room, including ID."""
id: int
model_config = ConfigDict(from_attributes=True)
class BookingBase(BaseModel):
"""Base schema for Booking."""
room_id: int
start_time: datetime
end_time: datetime
class BookingCreate(BookingBase):
"""Schema for creating a new Booking."""
model_config = ConfigDict(from_attributes=True)
class BookingResponse(BookingBase):
"""Response schema for Booking, including ID and related Room."""
id: int
room: RoomResponse
model_config = ConfigDict(from_attributes=True)
class InviteeBase(BaseModel):
"""Base schema for Invitee."""
booking_id: int
user_id: int
class InviteeCreate(InviteeBase):
"""Schema for creating a new Invitee."""
model_config = ConfigDict(from_attributes=True)
class InviteeResponse(InviteeBase):
"""Response schema for Invitee, including ID and related Booking and User."""
id: int
booking: BookingResponse
user: UserResponse
model_config = ConfigDict(from_attributes=True)

View File

@@ -0,0 +1 @@
"""Schemas package for the Numinar coding project backend."""

View File

@@ -0,0 +1,31 @@
"""Booking schemas for request and response validation."""
from datetime import datetime
from pydantic import BaseModel
from pydantic import ConfigDict
from backend.schemas.rooms import RoomResponse
class BookingBase(BaseModel):
"""Base schema for Booking."""
room_id: int
start_time: datetime
end_time: datetime
class BookingCreate(BookingBase):
"""Schema for creating a new Booking."""
model_config = ConfigDict(from_attributes=True)
class BookingResponse(BookingBase):
"""Response schema for Booking, including ID and related Room."""
id: int
room: RoomResponse
model_config = ConfigDict(from_attributes=True)

View File

@@ -0,0 +1,30 @@
"""Invitee schemas for request and response validation."""
from pydantic import BaseModel
from pydantic import ConfigDict
from backend.schemas.bookings import BookingResponse
from backend.schemas.users import UserResponse
class InviteeBase(BaseModel):
"""Base schema for Invitee."""
booking_id: int
user_id: int
class InviteeCreate(InviteeBase):
"""Schema for creating a new Invitee."""
model_config = ConfigDict(from_attributes=True)
class InviteeResponse(InviteeBase):
"""Response schema for Invitee, including ID and related Booking and User."""
id: int
booking: BookingResponse
user: UserResponse
model_config = ConfigDict(from_attributes=True)

View File

@@ -0,0 +1,27 @@
"""Room schemas for request and response validation."""
from pydantic import BaseModel
from pydantic import ConfigDict
class RoomBase(BaseModel):
"""Base schema for Room."""
name: str
location: str
equipment: str
capacity: int
class RoomCreate(RoomBase):
"""Schema for creating a new Room."""
model_config = ConfigDict(from_attributes=True)
class RoomResponse(RoomBase):
"""Response schema for Room, including ID."""
id: int
model_config = ConfigDict(from_attributes=True)

View File

@@ -0,0 +1,25 @@
"""User schemas for request and response validation."""
from pydantic import BaseModel
from pydantic import ConfigDict
class UserBase(BaseModel):
"""Base schema for User."""
email: str
name: str
class UserCreate(UserBase):
"""Schema for creating a new User."""
model_config = ConfigDict(from_attributes=True)
class UserResponse(UserBase):
"""Response schema for User, including ID."""
id: int
model_config = ConfigDict(from_attributes=True)