- Add preferred_name column to settings model/schema with migration - Settings page gets Profile card with name input (saves on blur/enter) - Dashboard greeting now shows "Good evening, Kyle." when name is set - WeekTimeline dots use event's actual color when available - New DayBriefing component shows time-of-day-aware contextual summary Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
50 lines
1.2 KiB
Python
50 lines
1.2 KiB
Python
from pydantic import BaseModel, ConfigDict, field_validator
|
|
from datetime import datetime
|
|
from typing import Literal, Optional
|
|
|
|
AccentColor = Literal["cyan", "blue", "green", "purple", "red", "orange", "pink", "yellow"]
|
|
|
|
|
|
def _validate_pin_length(v: str, label: str = "PIN") -> str:
|
|
if len(v) < 4:
|
|
raise ValueError(f'{label} must be at least 4 characters')
|
|
if len(v) > 72:
|
|
raise ValueError(f'{label} must be at most 72 characters')
|
|
return v
|
|
|
|
|
|
class SettingsCreate(BaseModel):
|
|
pin: str
|
|
|
|
@field_validator('pin')
|
|
@classmethod
|
|
def pin_length(cls, v: str) -> str:
|
|
return _validate_pin_length(v)
|
|
|
|
|
|
class SettingsUpdate(BaseModel):
|
|
accent_color: Optional[AccentColor] = None
|
|
upcoming_days: int | None = None
|
|
preferred_name: str | None = None
|
|
|
|
|
|
class SettingsResponse(BaseModel):
|
|
id: int
|
|
accent_color: str
|
|
upcoming_days: int
|
|
preferred_name: str | None = None
|
|
created_at: datetime
|
|
updated_at: datetime
|
|
|
|
model_config = ConfigDict(from_attributes=True)
|
|
|
|
|
|
class ChangePinRequest(BaseModel):
|
|
old_pin: str
|
|
new_pin: str
|
|
|
|
@field_validator('new_pin')
|
|
@classmethod
|
|
def new_pin_length(cls, v: str) -> str:
|
|
return _validate_pin_length(v, "New PIN")
|