Initial commit
This commit is contained in:
35
backend/app/schemas/settings.py
Normal file
35
backend/app/schemas/settings.py
Normal file
@@ -0,0 +1,35 @@
|
||||
"""Settings schemas."""
|
||||
|
||||
from pydantic import BaseModel
|
||||
from typing import Optional, Any
|
||||
from datetime import datetime
|
||||
|
||||
|
||||
class SettingBase(BaseModel):
|
||||
"""Base setting schema."""
|
||||
key: str
|
||||
value: Any
|
||||
|
||||
|
||||
class SettingUpdate(BaseModel):
|
||||
"""Schema for updating a setting."""
|
||||
value: Any
|
||||
|
||||
|
||||
class Setting(BaseModel):
|
||||
"""Setting schema for responses."""
|
||||
key: str
|
||||
value: Any
|
||||
updated_at: datetime
|
||||
|
||||
class Config:
|
||||
from_attributes = True
|
||||
|
||||
@classmethod
|
||||
def from_orm(cls, obj):
|
||||
"""Custom from_orm to handle value extraction."""
|
||||
return cls(
|
||||
key=obj.key,
|
||||
value=obj.get_value(),
|
||||
updated_at=obj.updated_at
|
||||
)
|
||||
Reference in New Issue
Block a user