mirror of
https://github.com/fastapi/fastapi.git
synced 2026-01-03 19:50:52 -05:00
* 🌐 Refactor file structure to support internationalization * ✅ Update tests changed after i18n * 🔀 Merge Typer style from master * 🔧 Update MkConfig with Typer-styles * 🎨 Format mkdocs.yml with cannonical form * 🎨 Format mkdocs.yml * 🔧 Update MkDocs config * ➕ Add docs translation scripts dependencies * ✨ Add Typer scripts to handle translations * ✨ Add missing translation snippet to include * ✨ Update contributing docs, add docs for translations * 🙈 Add docs_build to gitignore * 🔧 Update scripts with new locations and docs scripts * 👷 Update docs deploy action with translations * 📝 Add note about languages not supported in the theme * ✨ Add first translation, for Spanish
50 lines
848 B
Python
50 lines
848 B
Python
from typing import Any, List
|
|
|
|
import peewee
|
|
from pydantic import BaseModel
|
|
from pydantic.utils import GetterDict
|
|
|
|
|
|
class PeeweeGetterDict(GetterDict):
|
|
def get(self, key: Any, default: Any = None):
|
|
res = getattr(self._obj, key, default)
|
|
if isinstance(res, peewee.ModelSelect):
|
|
return list(res)
|
|
return res
|
|
|
|
|
|
class ItemBase(BaseModel):
|
|
title: str
|
|
description: str = None
|
|
|
|
|
|
class ItemCreate(ItemBase):
|
|
pass
|
|
|
|
|
|
class Item(ItemBase):
|
|
id: int
|
|
owner_id: int
|
|
|
|
class Config:
|
|
orm_mode = True
|
|
getter_dict = PeeweeGetterDict
|
|
|
|
|
|
class UserBase(BaseModel):
|
|
email: str
|
|
|
|
|
|
class UserCreate(UserBase):
|
|
password: str
|
|
|
|
|
|
class User(UserBase):
|
|
id: int
|
|
is_active: bool
|
|
items: List[Item] = []
|
|
|
|
class Config:
|
|
orm_mode = True
|
|
getter_dict = PeeweeGetterDict
|