42 lines
875 B
Python
42 lines
875 B
Python
"""Family schemas"""
|
|
|
|
from pydantic import BaseModel
|
|
from datetime import datetime
|
|
from typing import Optional, List
|
|
|
|
|
|
class FamilyMemberSchema(BaseModel):
|
|
"""Family member schema"""
|
|
id: int
|
|
user_id: int
|
|
role: str
|
|
can_edit_budget: bool
|
|
can_manage_members: bool
|
|
joined_at: datetime
|
|
|
|
class Config:
|
|
from_attributes = True
|
|
|
|
|
|
class FamilyCreateSchema(BaseModel):
|
|
"""Schema for creating family"""
|
|
name: str
|
|
description: Optional[str] = None
|
|
currency: str = "RUB"
|
|
notification_level: str = "all"
|
|
accounting_period: str = "month"
|
|
|
|
|
|
class FamilySchema(FamilyCreateSchema):
|
|
"""Family response schema"""
|
|
id: int
|
|
owner_id: int
|
|
invite_code: str
|
|
is_active: bool
|
|
created_at: datetime
|
|
updated_at: datetime
|
|
members: List[FamilyMemberSchema] = []
|
|
|
|
class Config:
|
|
from_attributes = True
|