24 lines
682 B
Python
24 lines
682 B
Python
# app/schemas/group.py
|
|
from pydantic import BaseModel, ConfigDict
|
|
from datetime import datetime
|
|
from typing import Optional, List
|
|
|
|
from .user import UserPublic # Import UserPublic to represent members
|
|
|
|
# Properties to receive via API on creation
|
|
class GroupCreate(BaseModel):
|
|
name: str
|
|
|
|
# Properties to return to client
|
|
class GroupPublic(BaseModel):
|
|
id: int
|
|
name: str
|
|
created_by_id: int
|
|
created_at: datetime
|
|
members: Optional[List[UserPublic]] = None # Include members only in detailed view
|
|
|
|
model_config = ConfigDict(from_attributes=True)
|
|
|
|
# Properties stored in DB (if needed, often GroupPublic is sufficient)
|
|
# class GroupInDB(GroupPublic):
|
|
# pass |