45 lines
1.2 KiB
Python
45 lines
1.2 KiB
Python
from pydantic import BaseModel, Field
|
|
from typing import Optional
|
|
from uuid import UUID
|
|
from fastapi_users import schemas
|
|
import uuid
|
|
from app.schemas.pessoa_schemas import PessoaBaseResponse
|
|
|
|
|
|
class PermissionRead(BaseModel):
|
|
id: int = Field(..., description="Unique identifier for the permission")
|
|
nome: str = Field(..., max_length=50, description="Name of the permission")
|
|
|
|
class Config:
|
|
from_attributes = True
|
|
|
|
|
|
class RoleRead(BaseModel):
|
|
uuid: UUID = Field(..., description="Unique identifier for the role")
|
|
nome: str = Field(..., max_length=50, description="Name of the role")
|
|
|
|
permissoes: list[PermissionRead] = Field(..., description="List of permissions associated with the role")
|
|
|
|
class Config:
|
|
from_attributes = True
|
|
|
|
|
|
class UserRead(schemas.BaseUser[uuid.UUID]):
|
|
nome_completo: str = Field(min_length=3, max_length=100)
|
|
fk_inquilino_uuid: UUID
|
|
papeis: list[RoleRead]
|
|
# pessoa: PessoaBaseResponse
|
|
|
|
|
|
class UserCreate(schemas.BaseUserCreate):
|
|
fk_inquilino_uuid: UUID
|
|
nome: str = Field(min_length=3, max_length=100)
|
|
|
|
|
|
class UserUpdate(schemas.BaseUserUpdate):
|
|
pass
|
|
|
|
|
|
class UserRoles(BaseModel):
|
|
papeis: list[UUID]
|