b87ad0e7ad
Asking for a full week off never spent anything on the Saturday, the Sunday or a holiday, and a test now says so outright rather than leaving it to be rediscovered. Those days are free because vacation cannot be taken on a day that is not a working day. Parental benefit is a payment rather than a schedule, though, so it can be drawn on a red day to turn an unpaid day off into a paid one — at the cost of a day the family would otherwise keep. That is now a workspace setting, off by default, and it never reaches for a vacation day. With it off the planner behaves exactly as before. Co-Authored-By: Claude Opus 5 <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_01Ei7gCZzdd751uZtPzb1Pep
82 lines
2.1 KiB
Python
82 lines
2.1 KiB
Python
"""Pydantic schemas for workspace and invitation endpoints."""
|
|
|
|
from datetime import datetime
|
|
from uuid import UUID
|
|
|
|
from pydantic import BaseModel, Field
|
|
|
|
from app.entities.workspace import Workspace
|
|
from app.entities.workspace_invitation import WorkspaceInvitation
|
|
|
|
|
|
class WorkspaceCreate(BaseModel):
|
|
name: str = Field(min_length=1, max_length=100)
|
|
|
|
|
|
class WorkspaceUpdate(BaseModel):
|
|
name: str | None = Field(default=None, min_length=1, max_length=100)
|
|
# §todo item 2 — `None` means "leave unchanged"; only an explicit
|
|
# true/false updates the stored flag (mirrors `name`'s omit-to-keep
|
|
# convention above).
|
|
take_pl_on_red_days: bool | None = None
|
|
|
|
|
|
class WorkspaceResponse(BaseModel):
|
|
id: UUID
|
|
name: str
|
|
created_at: datetime | None
|
|
take_pl_on_red_days: bool
|
|
|
|
@classmethod
|
|
def from_entity(cls, ws: Workspace) -> "WorkspaceResponse":
|
|
return cls(
|
|
id=ws.id,
|
|
name=ws.name,
|
|
created_at=ws.created_at,
|
|
take_pl_on_red_days=ws.take_pl_on_red_days,
|
|
)
|
|
|
|
|
|
class PersonalDataResponse(BaseModel):
|
|
uuid: UUID
|
|
workspace_id: UUID
|
|
name: str
|
|
salary_type: str
|
|
employment_status: str
|
|
created_at: datetime | None
|
|
|
|
|
|
class PersonalDataCreate(BaseModel):
|
|
"""Request body for both adding a placeholder parent (POST) and renaming
|
|
|
|
one (PATCH) — both take exactly one field, so one schema serves both.
|
|
"""
|
|
|
|
display_name: str = Field(min_length=1, max_length=100)
|
|
|
|
|
|
class InviteResponse(BaseModel):
|
|
token: str # raw one-time token — share out-of-band; not stored on backend
|
|
|
|
|
|
class RedeemInviteRequest(BaseModel):
|
|
token: str
|
|
|
|
|
|
class InvitationResponse(BaseModel):
|
|
id: UUID
|
|
workspace_id: UUID
|
|
status: str
|
|
expires_at: datetime
|
|
created_at: datetime
|
|
|
|
@classmethod
|
|
def from_entity(cls, inv: WorkspaceInvitation) -> "InvitationResponse":
|
|
return cls(
|
|
id=inv.id,
|
|
workspace_id=inv.workspace_id,
|
|
status=inv.status,
|
|
expires_at=inv.expires_at,
|
|
created_at=inv.created_at,
|
|
)
|