mirror of
https://github.com/xlorepdarkhelm/numinar-coding-project.git
synced 2026-09-07 02:28:26 -04:00
Restructured the schemas correctly now too.
Signed-off-by: Cliff Hill <xlorep@darkhelm.org>
This commit is contained in:
@@ -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)
|
||||
1
backend/src/backend/schemas/__init__.py
Normal file
1
backend/src/backend/schemas/__init__.py
Normal file
@@ -0,0 +1 @@
|
||||
"""Schemas package for the Numinar coding project backend."""
|
||||
31
backend/src/backend/schemas/bookings.py
Normal file
31
backend/src/backend/schemas/bookings.py
Normal 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)
|
||||
30
backend/src/backend/schemas/invitees.py
Normal file
30
backend/src/backend/schemas/invitees.py
Normal 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)
|
||||
27
backend/src/backend/schemas/rooms.py
Normal file
27
backend/src/backend/schemas/rooms.py
Normal 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)
|
||||
25
backend/src/backend/schemas/users.py
Normal file
25
backend/src/backend/schemas/users.py
Normal 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)
|
||||
Reference in New Issue
Block a user