Initial commit
This commit is contained in:
@@ -0,0 +1,54 @@
|
||||
"""API schemas (Pydantic) for PlannedLeaveDay.
|
||||
|
||||
Schemas validate request bodies and shape responses. Separate from domain entities
|
||||
so the wire format can evolve independently.
|
||||
"""
|
||||
|
||||
from datetime import date, datetime
|
||||
from uuid import UUID
|
||||
|
||||
from pydantic import BaseModel, Field
|
||||
|
||||
from app.entities.planned_leave import PlannedLeaveDay
|
||||
|
||||
|
||||
class PlannedLeaveDayCreate(BaseModel):
|
||||
workspace_id: UUID
|
||||
child_id: UUID
|
||||
parent_personal_data_uuid: UUID
|
||||
date: date
|
||||
day_type: str = Field(pattern="^(sjukpenning|lagsta|vacation)$")
|
||||
is_dubbeldag: bool = False
|
||||
|
||||
|
||||
class PlannedLeaveDayUpdate(BaseModel):
|
||||
"""Partial update — all fields optional."""
|
||||
|
||||
day_type: str | None = Field(None, pattern="^(sjukpenning|lagsta|vacation)$")
|
||||
is_dubbeldag: bool | None = None
|
||||
|
||||
|
||||
class PlannedLeaveDayResponse(BaseModel):
|
||||
id: UUID
|
||||
workspace_id: UUID
|
||||
child_id: UUID
|
||||
parent_personal_data_uuid: UUID
|
||||
date: date
|
||||
day_type: str
|
||||
is_dubbeldag: bool
|
||||
created_at: datetime | None
|
||||
updated_at: datetime | None
|
||||
|
||||
@classmethod
|
||||
def from_entity(cls, entity: PlannedLeaveDay) -> "PlannedLeaveDayResponse":
|
||||
return cls(
|
||||
id=entity.id,
|
||||
workspace_id=entity.workspace_id,
|
||||
child_id=entity.child_id,
|
||||
parent_personal_data_uuid=entity.parent_personal_data_uuid,
|
||||
date=entity.date,
|
||||
day_type=entity.day_type,
|
||||
is_dubbeldag=entity.is_dubbeldag,
|
||||
created_at=entity.created_at,
|
||||
updated_at=entity.updated_at,
|
||||
)
|
||||
Reference in New Issue
Block a user