48 lines
1.0 KiB
Python
48 lines
1.0 KiB
Python
from typing import Optional
|
|
from datetime import date
|
|
from pydantic import BaseModel
|
|
|
|
# Import at the top to avoid circular imports
|
|
from app.schemas.user import User as UserOut
|
|
|
|
|
|
# Shared properties
|
|
class TeacherBase(BaseModel):
|
|
teacher_id: Optional[str] = None
|
|
date_of_birth: Optional[date] = None
|
|
address: Optional[str] = None
|
|
phone_number: Optional[str] = None
|
|
department: Optional[str] = None
|
|
hire_date: Optional[date] = None
|
|
user_id: Optional[int] = None
|
|
|
|
|
|
# Properties to receive via API on creation
|
|
class TeacherCreate(TeacherBase):
|
|
teacher_id: str
|
|
user_id: int
|
|
|
|
|
|
# Properties to receive via API on update
|
|
class TeacherUpdate(TeacherBase):
|
|
pass
|
|
|
|
|
|
class TeacherInDBBase(TeacherBase):
|
|
id: Optional[int] = None
|
|
|
|
class Config:
|
|
from_attributes = True
|
|
|
|
|
|
# Additional properties to return via API
|
|
class Teacher(TeacherInDBBase):
|
|
pass
|
|
|
|
|
|
# Teacher with User details
|
|
class TeacherWithUser(Teacher):
|
|
user: Optional[UserOut] = None
|
|
|
|
# Update forward refs
|
|
TeacherWithUser.model_rebuild() |