Files
F-r-ldraledigplannerare/backend/app/models/workspace.py
T
jacobh2 cc3ced905e Link planned days to their wish, fix the age-4 cap, drop the planning goal
Three changes that together unblock treating a calendar period as one
editable object.

Migration 008 adds `planned_leave_day.wish_id` (nullable, ON DELETE SET NULL)
so a persisted day knows which `leave_wish` produced it, `is_pinned` to mark a
day the user hand-edited, and `leave_wish.target_days` so a period drawn on a
calendar need not be a whole number of weeks. Apply-time identity still keys on
day_type/is_dubbeldag only, so a wish_id-only difference is a metadata update
rather than a collision.

The age-4 savable ceiling was applying the per-child figure of 96 to each
parent's pool, modelling a two-parent family as able to save 192 days past the
child's fourth birthday. `resolve_age4_savable_cap` is now the single place
that decides 48 (couple with two parents) versus 96 (everyone else), and both
AnalyticsService and the allocator read it.

Migration 009 drops `workspace.planning_goal` and `leave_wish.goal_override`.
The allocator's tier-3 policy collapses to one rule; `salary_type` still
branches, since that reflects what a vacation day actually costs a parent
rather than a user preference.
2026-09-15 20:28:06 +02:00

79 lines
1.9 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)
planning_mode: str | None = None
class WorkspaceResponse(BaseModel):
id: UUID
name: str
planning_mode: str
created_at: datetime | None
@classmethod
def from_entity(cls, ws: Workspace) -> "WorkspaceResponse":
return cls(
id=ws.id,
name=ws.name,
planning_mode=ws.planning_mode,
created_at=ws.created_at,
)
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,
)