Neda/Back/domains/groups/schemas.py
2026-03-28 20:49:16 +03:30

39 lines
1.3 KiB
Python

import uuid
from pydantic import BaseModel, Field
from domains.groups.models import GroupType, GroupMemberRole
class GroupCreate(BaseModel):
name: str = Field(..., max_length=50, description='name of the group')
class AdminGroupCreate(BaseModel):
name: str = Field(..., max_length=50, description='name of the group')
class GroupResponse(BaseModel):
id: uuid.UUID = Field(...)
name: str = Field(..., max_length=50, description='name of the group')
type: GroupType = Field(..., description='type of the group')
owner_id: uuid.UUID = Field(...)
is_active: bool = Field(..., description='is active')
class Config:
from_attributes = True
class AddMemberRequest(BaseModel):
username: str = Field(..., max_length=20, description='username of the user')
class AdminAddMemberRequest(BaseModel):
username: str = Field(..., max_length=20, description='username of the user')
role: GroupMemberRole = Field(GroupMemberRole.MEMBER, description='role of the user in the group')
class GroupMemberResponse(BaseModel):
user_id: uuid.UUID = Field(...)
username: str = Field(..., max_length=20, description='username of the user')
role: GroupMemberRole = Field(..., description='role of the user in the group')
is_online: bool = Field(False, description='is online')
class Config:
from_attributes = True